It depends on many factors.
1. Caching
When you separate your javascript or css into separate files, it will be cached in the browser, and when a new request arrives, there is no need to download a new one from the browser. But in the case of built-in encoding, every time a page is requested, content will be downloaded that will increase bandwidth usage.
Read more in Make JavaScript and CSS External
2. Reduce the HTTP request
By creating inline encoding, you can reduce the number of HTTP requests, which are one way to optimize the page.
For more information, see Collapse HTTP Requests.
3. Maintainability
When creating an external javascript and css file, it will be easier to maintain the code. You do not change each page to make changes.
4. Minification
Minimization is the practice of removing unnecessary characters from code in order to reduce its size, thereby increasing load time. When the code is minimized, all comments are deleted, as well as unnecessary space characters (space, new line and tab). In the case of JavaScript, this improves response performance because the size of the downloaded file is reduced.
Read more in Minimize JavaScript
Here I found a good article on
Javascript Loaded
rahul
source share