What this codes mean?

Somewhere along the codes of my app.
I found these codes below,

    <script>window.jQuery || document.write('<script src="js/vendor/jquery-1.11.3.min.js"></script>');</script>

Can someone explain to me what this codes mean in plain english please?

In brief, it loads the jQuery library if it hasn’t yet already been loaded by something else on the page.

The double pipe symbol is an or condition. If window.jQuery is truthy it goes no further, and if it’s falsy it goes on to load the jQuery library.

hi paul

thanks for explaining.

Actually, I have two lines of codes loading jquery.
That one below which is located in the body section of the script.
And another one on the head section.

So is it right to remove this codes loading the jquery on the body section of the script?
Since there is already a script loading jquery on the head section?

thans in advance

It is best to leave the line there. It is a safety mechanism that will ensure that things keep working if ever changes are made to remove the other jQuery that you are currently using.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.