Reputation: 29735
I've recently moved a site over to use the Google AJAX Libraries instead of hosting the library js files myself. At the moment I'm using the Google recommended approach:
<script type="text/javascript" src="http://www.google.com/jsapi?key=MYAPIKEY"></script>
<script type="text/javascript">google.load('jquery', '1.3.2');</script>
But it seems a little silly to me to include an extra JavaScript file, just so I can call another script file.
My question is, is there actually any advantage to calling these files via google.load()
as opposed to simply including them via script tag like so:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
My main reasons for using the Google hosted libraries are the speed of their CDN/edge caching systems; am I still getting those benefits if I link directly to the file?
Upvotes: 3
Views: 630
Reputation: 22418
the main advantage for using the loader api is that you will prevent blocking by the browser when its doing the initial downloads. Browsers can only download between 2 & 10 things at a time so if there is blocking it will give bad user experience
Steve Souders and the Yahoo! Exceptional Performance team have done a lot of research into this to get faster websites. Nick Zakas (JavaScript guru) blogged about using Steve's ideas here
Upvotes: 3