javascriptjqueryperformanceincludejscompress

jQuery/JavaScript - performance-issue when having a lot of small .js-Files?


i've got a site with a lot of referenced .js-Files; those are rather small files, but I want to keep my methods separated by topic/functionality.

Is it better to keep all the methods in one .js-File or is it no problem to have many (~ 20 - 30) small files all including only some lines?


Solution

  • By all means keep them separate for development, but you should consider bundling them together into one file for production.

    There is a nice discussion at sitepoint.com

    For each of these files, an HTTP request is sent to the server, and then the browser awaits a response before requesting the next file. Limits (or limitations) of the browser generally prevent parallel downloads. This means that for each file, you wait for the request to reach the server, the server to process the request, and the reply (including the file content itself) to reach you. Put end to end, a few of these can make a big difference to page load times.