<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="js/vendor/jquery-1.8.3.min.js"><\/script>')</script>
Boilerplate js file calling methods
1- Why calling two times on the same file..?
2- What is the different second one calling method..?
The first line loads jQuery from Google's Content Distribution Network (CDN). It's likely that it's already be in someone's cache, so it'll load super-fast for them.
The second line literally means window.jQuery OR load a local copy
. Essentially, if the first line of code succeeded, window.jQuery
will exist and the bit after the ||
doesn't get executed. If not (site is down, or some other error occurred), the browser jumps to the OR condition, and loads a local copy instead.