**Warning: js compressed please manual confirmation before put into production use, does not guarantee 100% operational, js and js souche.com official website of the current test have been tested, which can guarantee there is no problem after 99% compression of js
js2image Is a javascript source code can be compressed into a single source code ascii character painting tool, which features code compression can still run after, rather than simply makes up the final pattern.
About js2image principle can see this article i writed:Christmas, all the js code of the site compress into a Christmas tree。
http://f2e.souche.com/assets/js/lib/jquery-2.1.1.min.xmas.js
In addition, the project has more than one resource directory is already running through the test library file.
Compression effect is as follows:
# Ubuntu
$ sudo apt-get install graphicsmagick
# Fedora
$ sudo dnf install GraphicsMagick
# OS X
$ brew install graphicsmagick
# Chocolatey (package manager for Windows)
# (Restart of cmd/PowerShell is required)
$ choco install graphicsmagickExecute the following command to install global command:
$ npm install js2image -gusage:
# Execute this command directly from the command line to compression, default compress a file with the extension xmas.js。
# -s Source code path, necessary parameters!
# -r Are inverting images, optional
# -i Specifies the path of the image, default ./resource/tree.png optional
$ js2image -s ./resource/jquery.js
# Added support for all packaged in a folder js files, caution! Packaging does not guarantee js100% after running properly, through manual testing to confirm.
$ js2image -s ./resourcerun this commands:
$ npm install js2image --saveusage:
var Js2Image = require('js2image');
var image = './resource/tree.png';
var source = './resource/jquery.js';
var target = './target/xmas.js';
var options = {};
// get the result code
var sourceCode = fs.readFileSync(source);
Js2Image.getCode(sourceCode, image, options).then(function (code) {
console.log(code);
})
// or write into file
Js2Image.writeToFile(source, image, target, options).then(function (code) {
console.log(code);
});