Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> JavaScript

Module Python nào dùng để obfuscate (rối mã) JavaScript?


Có thể dùng module jsmin để minimize/obfuscate mã JavaScript bằng Python. Cài đặt jsmin:

$ pip install jsmin

Để dùng jsmin trong dự án Python minimize file js, ví dụ hello.js:

>>> from jsmin import jsmin >>> with open('hello.js') as js_file: ...     minified = jsmin(js_file.read()) >>> print minified

Bạn sẽ nhận mã JS minified in ra shell. Cũng dùng jsmin như công cụ dòng lệnh:

$ python -m jsmin hello.js

Đọc thêm về jsmin trên pypi: https://pypi.python.org/pypi/jsmin