Merging multiple javascript files

前端 未结 4 2017
暗喜
暗喜 2021-01-31 21:38

I\'ve read that merging several multiple javascript files into a single file improves performance, is that true?

If so, is there an easy and error-free way of merging t

4条回答
  •  孤城傲影
    2021-01-31 22:04

    If you have many javascript files, it can help to combine them and to minify them. By combining them into a single file, you reduce the number of connections and files that need to be downloaded from your site. By minifying them, you actually reduce the size of the files by removing white space, comments, and so forth. Take a look at JSMin and YUI Compressor.

    Edit: As other commenters indicate, combining files really only makes sense if users are actively using features from all the files. It wouldn't make sense to combine a large and rarely used javascript file in with all your commonly used functions.

提交回复
热议问题