Georges Krinker Georges Krinker - 6 months ago 31
Javascript Question

Good Practice with External JavaScript files

I'm new to JavaScript.

How should I split my functions across external scripts? What is considered good practice? should all my functions be crammed into one external

file or should I group like functions together?

I would guess more files mean more HTTP requests to obtain the script and that could slow down performance? However more files keep things organized: for example,
initializes things on load,
retrieves data from the server,
refer to UI handlers...

What's the pros advice on this?



As Pointy mentioned, you should try a tool. Try Grunt of Brunch, both are meant to help you in the build process, and you can configure them to combine all your files when you are ready for prod (also, minify, etc), while keeping separate files when you are developing.