For JavaScript and CSS files on websites, we often compress them to save server bandwidth and speed up website page rendering (File Download is faster, and web pages are certainly faster ). For websites that use a lot of JavaScript, JavaScript files may often be modified. It is also very troublesome to manually compress JavaScript files every time you release them, lazy people usually want to automate everything-this time using Yui compressor. net and web deployment project to automatically compress JS and CSS files during compilation. Of course, we usually do not want to compress in debug mode compilation, but we only want to compress in release mode compilation. Off-topic: it seems that some friends do not care about the debug compiling mode or the release compiling mode at all. He never paid attention to the compiling mode. During the release, the entire website will also be copied to the production server in the form of source code. They usually think it is easier to find errors-enable ASP. NET debug mode on the production server, disable custom error pages, and so on. I do not agree with this method to deploy ASP. NET applications. I prefer to use the release mode to compile websites and disable ASP. NET.
Debug mode, open the custom error page, of course, in this case there should be ASP. NET health monitoring, which needs to be recorded when an uncaptured exception occurs. It is best to automatically notify the administrator of serious errors.
1. First, go to the Yui compressor for. Net homepage to download the file:
Http://yuicompressor.codeplex.com/releases/view/36891
2. If the Web deployment project is not installed, download and install it:
Http://go.microsoft.com/fwlink? Linkid = 104956
3. Download The WDP example provided by the Yui compressor for. Net developer.
4. Create a WDP project in your solution
5. Copy the DLL file of Yui compressor for. Net to a proper location-convenient reference
6. open the WDP project file by using a text editor such as Notepad. You can also select the WDP project in solution manager, and choose "open project file" from the context menu to open the solution file in.
7. Follow the prompts In the example to add properties to the project file.
The steps seem a lot, but they are actually very simple. Once set, you don't need to manage them anymore-unless you add or delete files, it's a permanent task.
Note: The sample file will compress all specified JS or CSS files into one file. If you want to compress each file separately without merging it together, you need to set it in other ways. However, the setting method is not complex. You can modify the Yui compressor for. Net Code. However, you only need to modify the WDP file and use msbuild.
If the CSS article has Chinese, you need to pay attention to the setting of file encoding in WDP, generally use UTF-8 on it.
There is time to supplement the problem of separate compression of multiple files.