Aside from multiple-page access, when is it a better idea to use external js files than to embed scripts in a webpage?

Recommended Answers

All 3 Replies

I'd say it's always better to use external, since they can be cached separately.

To 'pile on' to pritaeas' answer, using exernal JS files is the way to go.
You will find that having the JS script separate from the HTML of the web page will have your Web page development/debugging/changing code life eased.
For changes to the JS, you can concentrate on the JS. If changing the HTML, you can concentrate on the HTML. For a web site with more than a 'few' pages, the mixing of the JS with the HTML can start to look like a 'jungle' of code.
The more you can separate the 'layers' of your pages, the better.

I go With External JS , But As Possible as u can , combine scripts in one file to reduce http request ( Remeber as possible as u can )

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.