johnuk — 2012-02-13T12:33:20-05:00 — #1
Ideally id like to be able to call in a library, then run a block of code all from a single file.
Is this possible?
immerse — 2012-02-13T13:21:18-05:00 — #2
Yes, you can manipulate the DOM by adding a script tag to the header while or after the page loads.
Something like this, found on Google:
var oHead = document.getElementsByTagName('HEAD').item(0);
var oScript= document.createElement("script");
johnuk — 2012-02-13T14:07:06-05:00 — #3
That works great loading the script in - but for some reason non of my code based on the prototype library works if I load things that way.
immerse — 2012-02-13T14:38:09-05:00 — #4
Maybe the prototype based code isn't being fired properly because of the late-loading of the library.
All code depending on the library should be loaded after the library. Perhaps there's some documentation on the Prototype site detailing this kind of late-loading?
johnuk — 2012-02-13T14:39:11-05:00 — #5
Yes thats my thinking, im pretty sure the prototype library is loading AFTER my code so I will see what I can dig up.
Thanks for all your help!
chris_upjohn — 2012-02-13T16:44:58-05:00 — #6
You can read more about it here http://requirejs.org/