Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>There is actually a more elegant solution, it's being used by the <code>BBC</code> for their responsive news website. </p> <p>It essentially detects browsers considered to be <code>new</code>, and thus would be compatible with <code>jQuery 2.0+</code>, and therefore leaves everything else as an <code>old</code> browser. You may be able to replicate this with <code>Require.js</code>, but the reality is you don't need to...</p> <pre><code>if(querySelector in document &amp;&amp; localStorage in window &amp;&amp; addEventListener in window) { //Add jQuery 2.0+ } else { //Add jQuery 1.9.0+ } //This is intended to be a flag that can be checked against to see if the jQuery library has been loaded into the browser. var jQueryVersion = 0; function jQueryRunning(ver) { //This could be "true", or could be a version number, it's largely down to your own system needs! jQueryVersion = ver; } </code></pre> <p><strong>Source:</strong> <a href="http://responsivenews.co.uk/post/18948466399/cutting-the-mustard" rel="nofollow">link</a></p> <p>You should add a callback function to each of the scripts for <code>jQuery</code>, that calls <code>jQueryRunning</code> with the parameter equal to it's version number, this may help you decide on further functions to run down the line, and has the benefit of letting you know when the jQuery code has been embedded <code>(just in case the connection is slow and it takes a while to download)</code>.</p> <p>If using <code>Require.js</code> this may not be something you want to be concerned about!</p> <p>I say this is a elegant solution because you're quite right, the issue isn't only old versions of <code>IE</code>, it's also older versions of <code>Firefox (before 3.5)</code> and old mobile browsers (if they even deal with javascript!)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload