JavaScript refactoring threshhold

I have determined the number of lines at which I suddenly develop a need to split a .js file into multiple files.

It is anywhere between 300 and 400.

I grow my JavaScript organically. I start out with a main.js, and add bits and pieces as I go along. The global vars and utility functions I put near the top, and the main function I put at the end.

Eventually I section it off by comment lines filled with /////////////////////////.

Then, somewhere around 350 lines, I split it out into whatever logical groups strike my fancy.

Advertisements

Tags: ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: