In my project, a lot of classes interact on the client side. Each class is in a separate file for ease of development. A good practice for increasing page load speed is to reduce the number of server requests. Therefore, the fewer files and images to include in the page, the faster it will load. In the case of drawings - CSS sprites will help reduce the number of requests. And in the case of js and css files, this is a file concatenation and compression. About this and talk.
A very handy tool with open source
js-builder
')
A great tool to create file concatenation in the correct order. Works with any extensions you ask. Also compresses js.
In my project I use the prototype.js library. Bilder when compressing prototype gives an exception. Therefore, I downloaded the source code and rewrote it so that the builder was engaged only in concatenation without compression. Reassembled dll
can be downloaded here.The builder also contains a console application. And this is what you need for the build.
Next, you need to compress the files that the builder generates.
For this purpose, I used
YUI Compressor . Excellent library with a high degree of compression.
It remains only to automate the build process. For this, I wrote a batch file (I work in windows).
It looks like (build.bat) like this
set path1 = D: \ Projects \ build \
% path1% JSBuilder \ JSBuildConsole.exe /path=%path1%MyHeritageBuild.jsb
java -jar% path1% yuicompressor-2.3.1 \ build \ yuicompressor-2.3.1.jar
% path1% build \ output_file_from_js_builder.js -o% path1% target-min.js
java -jar% path1% yuicompressor-2.3.1 \ build \ yuicompressor-2.3.1.jar
% path1% build \ style-all.css -o% path1% style-all-min.css
In my case, the js builder on output gives 2 files - css and js, and the compressor compresses them.
I hope this helps you create a convenient process for assembling files.
I took this article from my
techno blog on
www.kigorw.com