intoxicated_curveball
asked on
Best practice for jQuery ready scripts
This is a bit of a best practice question, I couldn't find the info on the web. My website is using several JavaScript functions (from the jQuery tools library). Of course they all require to be executed when the DOM is ready. My website is quite large - over 2000 content pages, and we are using a CMS. I'm wondering is it practical to have a globally loaded JavaScript ready document for all of these functions (even though they aren't being used on most pages)? Will it have any impact on the site speed, etc.?
ASKER
I'm still wondering about the impact of it having to read the JavaScript and search the DOM for the respective elements everytime, even though the JS file may be loaded in cache, it's still using processing resources.
What be great if anyone has some reference documents to best practices for these type of scenarios?
What be great if anyone has some reference documents to best practices for these type of scenarios?
Check this slide : http://www.slideshare.net/jeresig/testing-performance-analysis-and-jquery-14
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
sorry I don't think any of the answers are definite, please advise
The js file loaded will be cached at first load and then just used from cache.
But then the performance depends on what is done inside that js file.
If you will perform some checks - if something does not exists - a control for example then do not execute further then the impact will be very small.