improvements to javascript load functions, avoided global scope, removed funky javascript as template thing