Random Articles
-
Wireless service costs too much, and all but the carriers agree
Criticism of U.S. wireless carriers has reached a... -
HP's third quarter propped up by EDS buyout
Hewlett-Packard reported a 2 percent drop in... -
AJAX widget security is enabled
In an upgrade to one of its core technologies,... -
Intel unveils energy-efficient 48-core chip
Intel today unveiled an experimental 48-core chip... -
Court shuts down sites promising free government grants
A U.S. district court has shut down several Web...
| Combining Javascript & CSS |
|
|
|
| Written by Joo Trans |
| Thursday, 13 August 2009 19:14 |
|
Take for example the following URLs: http://www.mysite.com/javascript/prototype.js You can combine all these files to a single file by simply changing the URL to: The script will intercept the attempt to retrieve something from the javascript directory and will notice that you want to fetch multiple files at once. It will then concatenate the requested files, compress it and send it as one to the browser. onfigurating this script is easy. First you need to download ands ave as combine.php file. By default this script look in the javascript and css directory in the root of your website, but if you are currently using different directories you can change these values at the top of the combine.php script. Upload the combine.php script to the root of your website. Secondly you need to create a cache directory that is writable by the web server. Again, by default this script will look for the cache directory in the root of the website, but you can change this in the combine.php script. Finally you need to add the following code into your .htaccess file. RewriteEngine On Note: if your preexisting .htaccess file already uses URL rewriting you do not need to add the first two lines. You can simply add the last two lines to the bottom of the .htaccess file. |




Compressing the files will decrease the size of the data that needs to be transferred, it does not solve the problem that the browser can only download a limited number of files at the same time. If you have many different files that need to be loaded the browser will not optimally use the bandwidth it has access to.