Ask HN: Performance hit for jQuery Download?
4 comments
if you grab Jquery from Google, you'll get more performance especially in speed, as the browser need to download it only once and then can work with it on all sites
Read more here http://encosia.com/2008/12/10/3-reasons-why-you-should-let-g...
Read more here http://encosia.com/2008/12/10/3-reasons-why-you-should-let-g...
use google's ajax libraries. they do everything for you, including caching them properly.
http://code.google.com/apis/ajaxlibs/
http://code.google.com/apis/ajaxlibs/
Let google host it for you: http://code.google.com/apis/ajaxlibs/
Using Google's version also means that it will only be cached once between all the sites that use it. This is similar to what you're talking about with bundling it in the browser,
Using Google's version also means that it will only be cached once between all the sites that use it. This is similar to what you're talking about with bundling it in the browser,
You need to set the cache control for the file to some far off date in future. Doing this will make sure the browser doesn't download the file each and every time the users visits your website. If you are using Apache you add this to your conf file.
<FilesMatch "\.(jpg|jpeg|png|gif|js|css)$"> Header set Cache-Control "public" Header set Expires "26 June 2210 20:00:00 GMT" </FilesMatch>
<FilesMatch "\.(jpg|jpeg|png|gif|js|css)$"> Header set Cache-Control "public" Header set Expires "26 June 2210 20:00:00 GMT" </FilesMatch>
I really want my site to be snappy, but it seems that downloading JQuery, even when minified, can cause a decent performance hit.
Is this worry justified? If so, is there anything I can do? Can something like GWT do the same basic stuff that JQuery does (and thus reap the performance benefits from less code to DL)?
Also, if this is a problem, and since I see a lot of sites using jQuery these days, why can't the browsers bundle the framework in their browser so the user doesn't have to download it each HTTP hit (of course, using the bundled framework would be optional)?
Thank you.