This double pipe (||
) is the logical "or" operator. If jQuery has already been loaded on the page, window.jQuery
is defined so this part of the expression evaluates to true, and the second part is not evaluated. Otherwise, the second part is evaluated, and that part actually does something: the script
tag is appended to the document, causing the browser to load the resource at the given URL.
On Bootstrap's homepage (which uses Bootstrap), I can see that the line before that is:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.0.0/jquery.min.js" integrity="sha384-THPy051/pYDQGanwU6poAc/hOdQxjnOEXzbT+OuUAFqNqFjL+4IGLBgCJC3ZOShY" crossorigin="anonymous"></script>
So, yes, this tries to fetch jQuery from the CDN, and if it fails (e.g. server unavailable), the next line ensures that jQuery is loaded from a local copy.