Friday, May 21, 2010

How many jquery.js files do YOU have in your disk?

It seems that jquery is the most popular javascript framework among web developers out there. This is not a bad thing, of course. The bad thing, or should I've said "practice", is that almost all developers [need to] use their 'own' version of the library and they include it into their plugin/theme/application directories!

Don't get me wrong; I'm not (currently) using it to code anything, but yesterday I thought it could be a good start to find the library and check its contents in order to start learning & using it. To my surprise, when I checked into my hard disk, I found 50 jquery.js files (not to mention the 364 jquery.*\.js ones)! It looks like a waste of space and a source of possible incompatibilities to me, don't you think so?

Just try this command in a terminal:
locate -i jquery | grep "jquery.js"  | wc -l
or the 'full' version:
locate -i jquery | egrep "jquery.*\.js"  | wc -l
and see how many files it 'll report for your hard disk. If there are more than 10 (as in my case), I'd be worried.

I believe that all of that mess could be avoided if the developers used the Google-hosted versions of the library and avoided its inclusion into their directories.

On the other hand, if you are a developer and want to test your source files with a local version of the library, while providing the Google-API one to your visitors, you can use the is_me() [PHP function] to incorporate the appropriate jquery files.

0 comments:

Post a Comment