How can I get the callback to not run until the script is actually appended to the document?
function addScript(filepath, callback){ if (filepath) {
This tiny script / css loader will do the job https://github.com/rgrove/lazyload/
LazyLoad.js('/foo.js', function () { alert('foo.js has been loaded'); });