Home     |      Learn AJAX     |      Forum     |      Register     |      Submit Resource     |      Submit Article      |      Contact Us

Home AJAX-Tips
 

Optimize Your jQuery Application

 

jQuery has come a long a way from a simple library created by John Resig into one (if not) of the most popular JavaScript library today. The library enable developers to create JavaScript application with little coding required. The plug-ins developed everyday is staggering that almost any functions needed by developers could be found with the use of jQuery.


But using jQuery doesn’t automatically mean speed and efficiency. There are certain practices that developers must observe to ensure that their jQuery library has been optimized.


Minifying the Script


There are two reasons why you should minify your script: minimize footprint and increase processing time with the browser and; allow more functions to be implemented. Today’s browsers are very efficient in running various JavaScript functions at the same time. If they can’t, they also have the capability to queue the function effectively. If you minify your JavaScript, you increase the chances of adding more functions in your application. Some developers even recommend combining functions to push for more interaction with the user.


Avoid Classes and Embrace IDs


Using Class to identify sets of variables and data has been a good practice for many years. However, efficiency of class tagging in jQuery is not optimized. jQuery follows the standard coding for browsers which uses IDs instead of classes. Of course, your jQuery or JavaScript based application will still work as planned, but if you want something faster, consider using IDs.


This optimization technique for jQuery shows the reason why jQuery is a lot faster than most libraries. It will require developers to learn the library but it will take the side of browsers for compatibility. Since browsers are the ones running the functions, it’s just logical that jQuery should run faster than most JavaScript libraries.


Practice Caching


While caching has been practiced by many JavaScript developers for quite some time, many are still hesitant because of the caching problem that could arise anytime from the programming language. But jQuery goes the other way by advising developers to aggressively use caching in their application. Caching is recommended (or even required) in jQuery since it will help developers lessen the required function. Instead of rewriting the script for the browser to read, developers can just rely on cache. Since it has already been cached, you should expect that it will be executed faster.


Get the Latest jQuery


jQuery, like most JavaScript libraries, is an evolving library. Developers are constantly looking for ways to improve jQuery from its current coding practice. Before using the jQuery based plug-in you found online, check if the plug-in uses the latest version of jQuery. Contact the developer immediately if the version is not updated.


Applications based on jQuery that uses various versions can still run as expected. However, versions may not necessarily work in an optimized level since the browser will still figure out of the two functions can actually work with each other. By updating and unifying your jQuery, you’ll be able to build an optimized jQuery based application.



Read Next: PunyPNG For Image Compression



 

 

Comments



Post Your Comment:

Members Please Login
Your Name:*
e-mail ID:(required for notification)*
Image Verification: 
 
 Subscribe    

Sponsored Links