Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is it important to load a JS framework from Google's AJAX Libraries API?

I remember reading somewhere that it is a lot better to load a JS framework from Google's AJAX Libraries API, rather than using a locally hosted one.

This means that instead of :

<script src="jquery.js"></script>

You load the framework from Google:

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

I think that the advantage was mostly about caching but I'm not sure about it.

Can someone explain to me the reason exactly on why it is better to load frameworks from Google instead of hosting them locally ?

like image 626
Andreas Grech Avatar asked Dec 05 '22 04:12

Andreas Grech


1 Answers

There is a good chance another site will also be using the same js files from Google's servers, so the file will already be cached by your browser and it won't need to download it again for your site.

Check out this article for some of the other benefits as well.

like image 184
jamesaharvey Avatar answered Apr 06 '23 00:04

jamesaharvey