I want to preload a large JS file after the page loads, so when I link to this JS file on the desired page, it is already loaded and cached.
I basically do this at the moment, and it works, but of course it is not:
preload_js = new Image(); preload_js = "http://domain.com/files/file.js";
It seems such a quick and easy method, no Ajax is needed, etc., and it works great.
What is the right way to do this? Of course, not with Ajax, as that seems redundant for this.
I know many ways to load JS, but they all seem to actually run the code after the script loads, which I don't want.
I do not want to use jQuery (or any library), it should be plain JS. Thanks for any help.
user2143356
source share