shadowayex Posted February 8, 2011 Share Posted February 8, 2011 I was wondering about a way to "include" other JS files into a JS file.My aim is to have a few files with collections of related, useful functions, and then apply those functions in different projects, but make it so only the file containing the project has to be linked to the HTML file via script tag.I found one solution that was of the sort: document.write("<script type='text/javascript' src='myFunctions.js'></script>"); But I'm not sure if that is the best solution or not. Link to comment Share on other sites More sharing options...
Synook Posted February 8, 2011 Share Posted February 8, 2011 That is the general idea - document.write() will clear the screen, though, so if you want to load another JavaScript file after the page loads, then it is better to create the element another way, e.g. by writing to an elements innerHTML, or by using the DOM. Link to comment Share on other sites More sharing options...
Fmdpa Posted February 8, 2011 Share Posted February 8, 2011 I'm still waiting for the day that JS adopts a parallel feature to CSS @import. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.