Minify Your jQuery Code
On its own, jQuery is an extremely small–and thus fast–library. JQuery's convenient syntax makes codes written using jQuery smaller and faster as well. However, complex codes can still be large, and this can cause problems.
Each time a user visits a board, their browser has to download the page, all of its images, all of the CSS files, and all of the JavaScript files. On subsequent visits it might store these in its cache, which will make page loading faster. However, any time the browser needs to download them from the server, the page will load slower–and if the JavaScript files get larger, the page will load slower still. Now extend this to hundreds of users trying to access the same JavaScript file at the same time–a scenario all too likely if you release a popular code. Even the simplest codes start to slow things down.
How to Properly Compress Your Code
The solution to this dilemma is to compress your codes, or “minify” them. This is easier than it sounds. There are a variety of tools available to do it for you, so the only additional step you have to do prior to releasing your code is to run it through the compression tool.
Important: This should only be performed on external JavaScript files, not on the code you intend to have people place in their Board Template to edit!
Once you've minified your code, you can upload it and host it as you would any other JavaScript file.
Warning: Do not pack your codes. That is, do not use the Packer or any other tool that uses eval() and other such methods to “compress” your code. These methods of compression are inefficient, because although they make the file size smaller, it takes longer for the browser to decompress them on the other end.
Compression Resources
- YUI Compressor from Yahoo!