Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>See it in action: <kbd><strong><a href="http://jsfiddle.net/ExpertSystem/suWdq/" rel="nofollow noreferrer">Short Demo</a></strong></kbd></p> <hr> <p>You can define a function, like this:</p> <pre><code>function appendScript(pathToScript) { var head = document.getElementsByTagName("head")[0]; var js = document.createElement("script"); js.type = "text/javascript"; js.src = pathToScript; head.appendChild(js); } </code></pre> <p>And then call it with the appropriate argument (e.g. according to screen size), like this:</p> <pre><code>appendScript("path/to/file.js"); </code></pre> <hr> <p>If you also need to remove a script from <code>head</code> (e.g. based on its 'src' attribute), you can define a function, like this:</p> <pre><code>function removeScript(pathToScript) { var head = document.getElementsByTagName("head")[0]; var scripts = head.getElementsByTagName("script"); for (var i = 0; i &lt; scripts.length; i++) { var js = scripts[i]; if (js.src == pathToScript) { head.removeChild(js); break; } } } </code></pre> <p>And then call it with the appropriate argument (e.g. according to screen size), like this:</p> <pre><code>removeScript("path/to/file.js"); </code></pre> <hr> <p>Also, note that using <code>screen.width</code> returns the size of the user's screen (not the browser-window's width). </p> <p>If you need to get the window size you can use <code>$(window).width()</code> (using jQuery). If you want a "jQuery-free" solution, take a look at <strong><a href="https://stackoverflow.com/questions/3437786/how-to-get-web-page-size-browser-window-size-screen-size-in-a-cross-browser-wa">this answer</a></strong> for cross-browser alternatives.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

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