how to include jquery in another javascript file [duplicate]
Simply include the JavaScript for jQuery before you include your own JavaScript:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script><script src="path/to/your/script.js"></script>
Though others have suggested simply copying and pasting jQuery into your own JavaScript file, it's really better to include jQuery separately from a canonical source as that will allow you to take advantage of the caching that your browser and intermediate servers have done for that file.
var jq = document.createElement("script");jq.addEventListener("load", proceed); // pass my hoisted functionjq.src = "//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js";document.querySelector("head").appendChild(jq);function proceed () { // jQuery load complete, do your magic}
Just merge the files.
cat jquery.js >> a_javascript_file.js
Or, since you probably want jQuery first:
cat a_javascript_file.js jquery.js > tmp.js;mv tmp.js a_javascript_file.js