JS - one huge file or many small files? - where to draw a line?

前端 未结 5 1826
悲哀的现实
悲哀的现实 2021-01-04 04:36

Is there a good rule of thumb as to how big (in size) a JS file should be - that if it grows bigger than this it\'s good idea to split it into smaller files?

5条回答
  •  旧时难觅i
    2021-01-04 04:46

    Develop in as many files as you want. Organize your code to keep development manageable.

    Then, when you deploy, ship a minified/combined version of the code using a tool like Google Closure

    This is what jQuery does. They ship one file, but the actual source code is much more organized.

提交回复
热议问题