August 1st, 2013, 05:12 PM
For the benefit of your users' and your own server's bandwidth, whenever you use a library like prototype, jquery, scriptaculous, or whatever, consider pointing your links to a hosted Content Distribution Network such as Google's. Your users' browsers likely already have these cached, as they are used all over the place.
For example, instead of pointing to jQuery locally, just point your users to Google's copy:
(See how the src attribute doesn't start with the protocol name? The browser will use the proper protocol, http or https, to match the one in the URL bar.)
If you're concerned about the CDN's availability, you can back it up with a local copy:
If the client's browser couldn't reach ajax.googleapis.com, the next bit of script will see that no jQuery object has been loaded, and try to download the library from your server.
<script>window.jQuery || document.write("<script src='/path/to/your/scripts/jquery-1.10.2.min.js'>\x3C/script>")</script>
For a lot of people this will be uselessly old news. But many posts I've seen on this board since I came back indicate that this information needs to be out there in front of newer web developers.
August 23rd, 2013, 01:46 AM
Thanks for this wonderful post. Really a great post and very helpful for visitors.!!
September 16th, 2013, 08:20 AM
thanks to provide this useful information
Last edited by Kravvitz; September 16th, 2013 at 11:34 PM.