For website optimization, the combination of compression JS, CSS and other static content is one of the required courses, a can save bandwidth, two can reduce the HTTP request, and three speed up the site's access speed
For how to implement merge compression JS
Scheme one: Inherit IHttpModule, intercept HTTP, then get its <script src=*> tag, remove the JS file to merge into a resource file
Scenario Two: If you're using the Web solution for ASP. NET MVC 4, then of course you can use bundle technology.
Scenario Three: Do not rely on any server technology, local first merge compression before uploading
This paper focuses on the program three
To merge files, you can use the Copy command under DOS
1 copy jquery.min.js+jquery-migrate-1.1. 1. js+jquery.hoverintent.minified.js+validform_v5. 3.1. Js+jquery.cookie.js+the7.pw.js index.js/b
To compress the JS file, the UGLIFYJS is used here. For how to install UGLIFYJS, you can refer to this article
DOS commands are as follows
1 uglifyjs index.js-m-o index.min.js
In order to compress a JS, every time into the DOS clever code, is not the way ah, so you can build a bat file in the JS directory, each time to upload a point before the finished.
But that's enough, for lazy people like the program ape, the point is superfluous.
So can we use the pre-event generated by the project to invoke the bat file is not better?
In this way, each time the project is generated, the merged compressed version of JS, not beautiful
Finally in the page, we can directly refer to the compressed version of JS