Context-aware jQuery Code Execution – Are you loading code t

Ask your questions about the best ways to optimize your site to rank highly in the search engines. Learn how to fine tune your website for optimal search engine ranking and SEO.

Moderator: John55

Context-aware jQuery Code Execution – Are you loading code t

Postby rajiv123 » Tue Jul 27, 2010 2:57 am

There are some developers that will load all of the jQuery code for a site on every page, regardless of whether or not it’s going to be used there or not. (Don’t worry, if you’ve done this before, the good news is you can always change that habit!).

What you need to remember is that jQuery still has to take time to execute that code and if its not needed you can get a quick performance gain by checking whether you’re on a page which requires that script to run.

This can be achieved in many ways such as defining a class or ID unique to each page’s content and checking for it’s existence before you run it’s specific code or even through server-side processing if you want to run check on the filename being accessed.

As long as you can do your best to only load code that’s needed, you’ll get some quick performance boosts that may not have been there if you hadn’t thought about this in advance.
rajiv123
 
Posts: 36
Joined: Sun Jan 17, 2010 2:19 pm

Return to Optimization Tips & Techniques

Who is online

Users browsing this forum: No registered users and 2 guests

cron