Does the Google AJAX API Loader have an advantage over the direct link to files hosted on Google using a script tag?

I recently moved the site to use Google AJAX libraries instead of hosting the js library files myself. I am currently 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 for me to include an additional JavaScript file, so I can call another script file.

My question is whether there really is any advantage when calling these files through google.load(), rather than just including them through the script tag like this:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>

My main reasons for using Google hosted libraries are the speed of their CDN / edge caching systems; Do I still get these benefits if I directly contact the file?

+3
source share
1 answer

The main advantage of using the api loader is that you prevent the browser from blocking during the initial boot. Browsers can only load 2 and 10 things at a time, so if there is a lock, this will give a bad user experience.

Steve Souders and Yahoo! The Exceptional Performance team has done a lot of research to get faster websites. Nick Zakas (a JavaScript guru) wrote a blog about using Steve’s ideas here

+3
source

Source: https://habr.com/ru/post/1729683/


All Articles