georage Posted July 14, 2016 Share Posted July 14, 2016 In C you create functions/classes/methods in external files and reference them atop the main file ... I assume something like that exists in javascript because it is a pain to keep scrolling hither and yon to find stuff. My mouse wheel is about to give out! What is the best practice? Quote Link to comment Share on other sites More sharing options...
adam Posted July 14, 2016 Share Posted July 14, 2016 I recommend using Typescript. https://www.typescriptlang.org/docs/tutorial.html https://www.typescriptlang.org/docs/handbook/modules.html georage 1 Quote Link to comment Share on other sites More sharing options...
jerome Posted July 14, 2016 Share Posted July 14, 2016 You can split your code in as many different files as you need and download them all in your browser then. Just use a html script tag per file. And make sure to start your code only when everything is downloaded : window.onload = myStartFunction; // starts everything Once you think your code is ok, you can also concatenate all the files into a single one (and maybe minify it too), so only one file is downloaded georage 1 Quote Link to comment Share on other sites More sharing options...
georage Posted July 14, 2016 Author Share Posted July 14, 2016 thanks guys. that seems obvious now! Quote Link to comment Share on other sites More sharing options...
mattstyles Posted July 14, 2016 Share Posted July 14, 2016 There are also module systems you can use to create a single build, maybe check out browserify for a version of this that will soon be native in browsers Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.