This is driving me slightly bonkers, since it must surely be an easy thing to achieve. I've spent hours searching for the solution, but can only find a solution in the context of html (with embedded JS code).
I have a native javascript file (.js not .html), and all I want to do is to include/embed/load the code in from another javascript (library) file into that file. This is NOT html I'm talking about, it's pure unadulterated javascript. The solutions I've seen are all along the lines of http://ntt.cc/2008/02/10/4-ways-to-dynamically-load-external-javascriptwith-source.html.
All I want to be able to do is:
include('./lib/cooljslibfile.js');
// ... now use functions etc defined in the above library file
Surely, to write re-usable code that can be deployed in multiple scripts, there must be a way other than just copying and pasting the contents of cooljslibfile.js into my javascript file?