6 advantages of JavaScript in external files

Putting JavaScript into external files is one of my most common requests when doing code reviews. Here are six reasons to do it:

1. Performance due to Bundling
2. Security by obscurity due to minification – this is not real security but every little helps – if there’s a vulnerability this might help you find it before an attacker does
3. Scalability due to caching – whereas JavaScript in internal files is included in the HTML every time
4. Allows unit testing
5. Allows developers to put comments in code without exposing them to end users
6. Allows reusability across multiple pages

One thought on “6 advantages of JavaScript in external files

  1. Pingback: jQuery Fundamentals | Zombie Code Kill

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 )

Connecting to %s