Javascipt server-side compression merge

  java, javascript

The page uses multiple javascript, first optimize it, and want to compress and merge these js files on the server side.
Pass on front page


In a similar way (Taobao’s approach).
I don’t know how the backstage handled it.
The most crucial question is:I requested to go to the background, get parameters, read those files, compress and merge them, generate new files, and then how do I return them to the client? ? ?

Taobao should have used the features of tengine.

Mod_concat module This can combine multiple requests into one request. …

Here is an article on how to use it. …

The request parameter requires two question marks (‘? ?’ ) to activate the concat feature. multiple files are connected by commas (,)

<script type="text/javascript" src="??js/jquery.js,js/slide_original.js,count/count/count.js"></script>
这样,便可以将jquery.js 和 slide_original.js 以及 count.js三个js文件的请求合并为一个了。