I'm developing sites using Wordpress and I want to use the lates version of jQuery.
To make sure I use the lates version, I have found this piece of code from Binary Bonsai's example.
What I see, is that he actually links to jQuery at Google API.
So my question is, what is better.
To link to jQuery on an external page?
http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js
or to have the jquery file locally?wp_enqueue_script('jquery', '/js/jquery-1.4.2.min.js');
UPDATE
Thanks to Colin, the answer is actually here:
Why should I use Google's CDN for jQuery?
But tjust in case you don't have Google
in your search term, like me, I'll copy the answer from John Gietzen
It increases the parallelism available.
(Most browsers will only download 3 or 4 files at a time from any given site)
It increases the chance that there will be a cache-hit.
(As more sites follow this practice, more users have the file already ready.)
It ensures that the payload will be as small as possible.
(Google can pre-gzip-compress the file, making the time-to-download very small.)
It reduces the amount of bandwidth used by the server.
(Google is basically offering free bandwidth.)
It ensures that the user will get a geographically close response.
(Google has servers all over the world, further decreasing the latency.)
You can leave out the minor or dot versions when linking to the google CDN copies, like this:
Given this flexibility, I much prefer the remote version, it's quick to get bug fixes by just changing the URL and the file's loaded faster (in most cases) because it's pulled from another domain (and not in the count of parallel requests to your domain). There are other related questions on this, here and here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With