I rather enjoy adding practical eye-candy to the networking community I’ve been developing but as things start to stack up I worry about load times.
-
Is it truly faster to have users
load (a hopefully cached) copy of
jquery from Google’s repositories? -
Does using jQuery for AJAX calls
improve/reduce efficiency over basic
javascript xmlHTTP requests? -
Is there a practical way to cut down the number of included scripts? For example, I include jQuery and jQuery UI from google, table sorter, and a growl plug-in.
Yes. Google’s servers are geographically positioned to serve the page from the location closest to the user to improve performance.
jQuery uses
XmlHttpRequestinternally, so it won’t be any faster. It will only be as quick as the browser’s implementation of XmlHttpRequest.To cut down on scripts, you’d have to combine them all yourself and host them on your own servers/CDN. Google only provides a limited set of popular AJAX frameworks.
Where jQuery really shines is in its layers of abstraction that help you avoid dealing with cross-browser incompatibilities. In this regard, it does a fairly good job.
It also beats out many other JavaScript frameworks as far as performance. Remember, any time you add a layer of abstraction, you’re going to lose some runtime performance. Where you lose that runtime performance, you make up for it by the cost savings to your developers because they can easily develop JavaScript code.
Overall I wouldn’t be too concerned about jQuery performance unless you notice it becomes a problem. And in this case, try to identify bottlenecks and optimize those. Simply using jQuery is almost never the reason for a slow site.