1

I'm trying to learn Bootstrap and I was studying this example. I noticed that they include the Jquery library and other scripts at the bottom of the markup just before the end of the body-- this part I understand. What I don't get is why JQuery is included using two lines of markup, like this:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="../../assets/js/vendor/jquery.min.js"><\/script>')</script>

What is the purpose of the second line?

Is it meant to handle the case where the first line fails or is too slow? Does writing the script element using document.write guarantee an immediate load time? Or what is the purpose?

John Wu
  • 50,556
  • 8
  • 44
  • 80

0 Answers0