Is it better to have one big JavaScript file or multiple light files?

JavascriptWeb DevelopmentFront End Technology

To avoid multiple server requests, group your JavaScript files into one. Whatever you use for performance, try to minify JavaScript to improve the load time of the web page.

If you are using single page application, then group all the scripts in a single file.

If you are using multiple files, then minify all of your scripts and separate them into categories.

example

<script src =”/js/core.js”> - Place JavaScript to be used in every page.
This can be the core script of the file.
<script src =”/js/plugins.js”> - Place your plugins here

Rest, add other scripts in a JavaScript file. It’s good to maintain it in different files.

raja
Published on 16-Jan-2018 10:38:19
Advertisements