Skip to main content
Removed chatting. Removed useless bold and italic. Removed useless HTML tags. Corrected badly copy-pasted code. Shortened source code.
Source Link
Arseni Mourzenko
  • 139.2k
  • 32
  • 359
  • 544
On HTML5 Boilerplate they use this code for jQuery:

<!-- Load jQuery with a protocol relative URL; fall back to local if offline -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></scrip>
<script>window.jQuery || document.write('<script src="js/libs/jquery-1.7.2.min.js"><\/script>')</script> On HTML5 Boilerplate they use this code for jQuery:

The question is simple, what's more readable:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="js/libs/jquery-...

if (!jQuery) document.write( -local jQuery- ); What's more readable:

or

if (!window.jQuery) document.write(...);

window.jQuery || document.write( -local jQuery- ); or

window.jQuery || document.write(...);
On HTML5 Boilerplate they use this code for jQuery:

<!-- Load jQuery with a protocol relative URL; fall back to local if offline -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></scrip>
<script>window.jQuery || document.write('<script src="js/libs/jquery-1.7.2.min.js"><\/script>')</script>

The question is simple, what's more readable:

if (!jQuery) document.write( -local jQuery- );

or

window.jQuery || document.write( -local jQuery- );

On HTML5 Boilerplate they use this code for jQuery:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="js/libs/jquery-...

What's more readable:

if (!window.jQuery) document.write(...);

or

window.jQuery || document.write(...);
Source Link
Devin Rhode
  • 363
  • 1
  • 2
  • 10

Readability of || statements

On HTML5 Boilerplate they use this code for jQuery:

<!-- Load jQuery with a protocol relative URL; fall back to local if offline -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></scrip>
<script>window.jQuery || document.write('<script src="js/libs/jquery-1.7.2.min.js"><\/script>')</script>

The question is simple, what's more readable:

if (!jQuery) document.write( -local jQuery- );

or

window.jQuery || document.write( -local jQuery- );