lib.js: Good practice and generally a good idea
Posted: February 4th, 2011 | Author: bart | Filed under: Javascript, JQuery, Web Development | Tags: javascript, jquery, pagespeed, seo | No Comments »I recently stumbled upon an article on Six Revisions titled Are Current web design trends pushing us back to 1999?.
I found it to be a very interesting article. It mainly talks about how new trends in the web are barking up old problems, like the Flash splash page, or the shoutbox.
On thing I found very interesting was the part called Modern-Day Bloated, Cut-And-Paste Scripts.
Being involved with jQuery on a day-to-day basis, you start using some plugins, or even write some of your own.
But once you start stacking plugins, the browser has to load all of these plugins, generating more request. Which is generally a good idea.
Now whenever creating a new webproject, I use one JS file: lib.js. This JS file contains everything I need, it’s like a swiss pocket knife!
Structure is usually like following (depends on your project needs):
- jQuery
- jQuery UI
- Plugins
- $(document).ready(function(){ /**magic here **/});
You could argue by saying: but doesn’t the filesize increase by a lot, letting the user download a 250k file is quite a lot!
I agree, but play your cards right in server configuration with a little help from Google’s mod_pagespeed or simply by getting goot ETags or Expires headers, the load happens just once (!!). And the rest of your surfing experience stays snappy.

Leave a Reply