Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>jQuery is not loaded when you call "$(document).ready(function(){", because it is not yet included in the page, but loaded after the page loads.</p> <p>This can be solved by executing all your code after the jquery file is done loading:</p> <pre><code>&lt;script type='text/javascript'&gt; var element = document.createElement("script"); function downloadJSAtOnload() { element.src = "//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"; document.body.appendChild(element); var element2 = document.createElement("script"); element2.src = "jquery.validate.js"; document.body.appendChild(element2); var element3 = document.createElement("script"); element3.src = "fancybox/jquery.fancybox.pack.2.1.4.js"; document.body.appendChild(element3); } if (window.addEventListener) window.addEventListener("load", downloadJSAtOnload, false); else if (window.attachEvent) window.attachEvent("onload", downloadJSAtOnload); else window.onload = downloadJSAtOnload; &lt;/script&gt; &lt;script type="text/javascript"&gt; // Quick and dirty implementation, you should check for all the included files to be done loading, and create some sort of object that triggers an event that is called when alle the files are loaded element.onload = function { $(document).ready(function() { ... }); } &lt;/script&gt; </code></pre> <p>[Edit]: jQuery depended files are loaded before jQuery: You have to apply the same method and create the script objects of the other files after the jQuery script onload event fires. You indeed should not have to use $(document).ready() anymore, because the files are included at onload which is always after domready.</p> <pre><code>&lt;script type='text/javascript'&gt; function downloadJSAtOnload() { var element = document.createElement("script"); element.src = "//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"; document.body.appendChild(element); element.onload = function() { /jQuery is ready, now load the files that build on the jQuery framework var element2 = document.createElement("script"); element2.src = "jquery.validate.js"; document.body.appendChild(element2); var element3 = document.createElement("script"); element3.src = "fancybox/jquery.fancybox.pack.2.1.4.js"; document.body.appendChild(element3); } } if (window.addEventListener) window.addEventListener("load", downloadJSAtOnload, false); else if (window.attachEvent) window.attachEvent("onload", downloadJSAtOnload); else window.onload = downloadJSAtOnload; &lt;/script&gt; </code></pre>
 

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