Jump to content

How would I move my functions to another file like in C?


Recommended Posts

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?


Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...