Loading main javascript on every page? Or breaking it up to relevant pages?

Posted by Kyle on Pro Webmasters See other posts from Pro Webmasters or by Kyle
Published on 2012-06-27T08:07:05Z Indexed on 2012/06/27 9:23 UTC
Read the original article Hit count: 297

Filed under:
|
|
|
|

I have a 700kb decompressed JS file which is loaded on every page. Before I had 12 javascript files on each page but to reduce http requests I compressed them all into 1 file.

This file is ~130kb gzipped and is served over gzip. However on the local computer it is still unpacked and loaded on every page. Is this a performance issue?

I've profiled the javascript with firebug profiler but did not see any issues. The problem/illusion I am facing is there are jquery libraries compressed in that file that are sometimes not used on the current page.

For example jquery datatables is 200kb compressed and that is only loaded on 2 of my website pages. Another is jqplot and that is another 200kb.

I now have 400kb of excess code that isn't executed on 80% of the pages.

Should I leave everything in 1 file?

Should I take out the jquery libraries and load only relevant JS on the current page?

© Pro Webmasters or respective owner

Related posts about JavaScript

Related posts about jQuery