This article teaches you how to use the code to express their happy birthday wishes or love of the girl, specific how to apply we can divergent thinking, such as Valentine’s Day to crush the girl send a JS file in the past to vindicate, or tomb-sweeping Day when the code burn incense, memorial to the dead love and so on.

Let’s just look at the effect.

Online Address:

Github.com/xinyu198736…

This is the use of vue.js source compression, the most important point is that the compressed code can still run, that is to say, you can put the compressed code on the line, you can put the whole company’s front-end code compression as a confession of the goddess (fired don’t look for me), think is not very exciting!

It’s easy to compress this code yourself, using the js2Image library.

Github address: github.com/xinyu198736…

Run the following command to install the global command:

$ npm install js2image -g
Copy the code

Usage:

By default, a file with the xmas.js suffix will be compressed.
# -s source code path must be a parameter!
# -r Whether inverting images can be saved
# -i specifies the path of the image to use./resource/tree.png is used by default

$ js2image -s ./resource/jquery.js

# Add support for packing all JS files in a folder. It is not guaranteed that the JS100% will run properly after packaging. Please confirm by manual test.
$ js2image -s ./resource

$ js2image -s ./resource/jquery.js -i ./resource/tree.png
Copy the code

If you want to customize some specific parameters, you can use require

var Js2Image = require("./index.js");
var path = require("path");
var source = "./resource/vue.js";
var image = path.join(__dirname,"./resource/happy.png");
var out = source.replace(".js".".xmas.js"); Js2image.writetofile (source,image,out,{
    reverse:false,
    size:{
        width:70
    }
}).then(function(code){

});

Copy the code

Detailed technical implementation, you can see this article: Christmas, the site all JS code are compressed into a Christmas tree.

Have fun!