Compress JavaScript and CSS files to optimize website speed.
Referencing external JavaScript and/or CSS files from a web page considerably increases the load time. As a rule of thumb remember that each external file requires additional HTTP request by the browser, hence the time to render a page will increase. Every web developer worth their salt should make optimization their priority. Fortunately, since this is such a common issue many people have thought about it and came up with solutions.
Below is a list of few of these solutions to optimize your website by compressing JavaScript and CSS files.
But before you start optimizing your website, I recommend that you visit WebSiteOptimization to analyze your website. Save the results and after you are done with your optimization analyze your website again and compare the before and after results. I bet you will be pleasantly surprised.
- Make Your Pages Load Faster
“The idea is that you have one directory for CSS files and one directory for javascript files on your server. If you rewrite the URLs that point to these directories to a small script that intercepts the requests for those files. The script loads the file from disk and compresses it using gzip. It then sends that compressed file back to the browser. Given that JavaScript and CSS files compress really well this will greatly decrease the size of the data that is going to be transferred and thus decrease the time needed to download these files. Because this works completely transparently you do not need to change anything in your existing code.”
- Serving JavaScript Fast
“With our so-called “Web 2.0″ applications and their rich content and interaction, we expect our applications to increasingly make use of CSS and JavaScript. To make sure these applications are nice and snappy to use, we need to optimize the size and nature of content required to render the page, making sure we’re delivering the optimum experience. In practice, this means a combination of making our content as small and fast to download as possible, while avoiding unnecessarily refetching unmodified resources.”
- YUI Compressor for JavaScript and CSS
“The YUI Compressor is a JavaScript compressor which, in addition to removing comments and white-spaces, obfuscates local variables using the smallest possible variable name. This obfuscation is safe, even when using constructs such as ‘eval’ or ‘with’ (although the compression is not optimal is those cases) Compared to jsmin, the average savings is around 20%. The YUI Compressor is also able to safely compress CSS files. The decision on which compressor is being used is made on the file extension (js or css).”
- JSMin- The JavaScript Minifier
“JSMin is a filter which removes comments and unnecessary whitespace from JavaScript files. It typically reduces filesize by half, resulting in faster downloads. It also encourages a more expressive programming style because it eliminates the download cost of clean, literate self-documentation.”
- Packer – A JavaScript Compressor
Online JavaScript Compressor. You can also download PHP, perl and .NET versions of this tool. - CSS Formatter and Optimiser
CleanCSS is a powerful CSS optimizer and formatter. Basically, it takes your CSS code and makes it cleaner and more concise. It helps you get smaller CSS file sizes and better written code. The way the optimizer works actually lets you decide how much compression you want. From super compressed (virtually unreadable and editable by a human being) to visually pleasing. I prefer the standard setting because it gives you a little of both.
This is just a sampling of the tools available for optimizing JavaScript and CSS files. This is not an exhaustive list and I am sure you can find many more tools online. The point is to consider optimization when you design and develop your website. If you know any other optimization tool or technique send that to me and I’ll be glad to add that to this list.
Happy optimization!
Website Optimization Resources
January 7, 2008 @ 10:58 pm
[…] Adblock Plus Filter List The 7 Habits for Exceptional Performance (Yahoo! Developer Network blog) Compress JavaScript and CSS files to optimize website speed. Search Engine Optimization » Blog Archive » What does actual.. Heal Your Church WebSite […]
Eva Wilder
November 12, 2008 @ 3:26 pm
4a4jlt1v9i7its0u
ekoder
February 21, 2011 @ 8:15 am
There is one more tool for js compression http://www.webrankstats.com/tools/javascript-compressor/
and for css compression http://www.webrankstats.com/tools/css-compressor/
hill climb ford street racing crack
June 14, 2014 @ 9:21 pm
When some one searches for his necessary thing, so
he/she wishes to be available that in detail, thus that thing is maintained over here.
camfrog generator code pro limited version 1.5.7
July 5, 2014 @ 8:15 am
It’s an awesome piece of writing in favor of
all the internet users; they will get advantage from it I am
sure.
robocop font generator
July 6, 2014 @ 11:24 pm
Hi! This is my 1st comment here so I just wanted to give a quick shout out and
tell you I truly enjoy reading your blog posts. Can you suggest
any other blogs/websites/forums that deal with the same subjects?
Thanks a ton!
dealdash top tips
July 12, 2014 @ 1:33 am
Hello, Neat post. There is an issue together with your website in web explorer, might check
this? IE still is the market leader and a big element of people will miss your magnificent writing
due to this problem.
Creditcard zonder BKR toetsing aanvragen
August 25, 2014 @ 1:00 pm
It is similar to a store gift card in that a certain amount of money
has been loaded on it. Over the past couple of years an increasing number of consumers have turned to prepaid credit cards for one of a number of reasons, and these plastic cards
are able to offer a range of benefits to consumers.
Our professionals study and analyze the industry and its various components, with comprehensive study of
the changing market behavior.