Does minified javascript improve performance?

后端 未结 8 1730
渐次进展
渐次进展 2020-11-27 05:26

I\'m making an AIR application (so download time doesn\'t have a huge impact), does combining and minifing all the javascript files affect the performance? How would obfusca

8条回答
  •  盖世英雄少女心
    2020-11-27 05:40

    Everyone here already talked about minifying but nobody talked about the 2nd part of your question - combining. This will definitely improve performance, probably even more than minifying.

    Multiple files require multiple HTTP requests, so when you put them all into one file, only 1 request is needed. This is important for 2 reasons:

    • each individual HTTP request may take longer to load for various routing reasons, and 1 file will potentially delay your whole application.
    • browsers and other clients have a max limit of files they are allowed to download concurrently from a single domain. Depending on the number of files in your application, this may mean the client queuing them up, thus making the load even longer.

    Also, besides minifying and combining, you have to absolutely make sure you have some sort of server side compression enabled. This can save you 90% or even more in the amount of bytes transferred, depending on the files.

    You can read more about compression (gzip, deflate) here: http://beerpla.net/2009/06/09/how-to-make-your-site-lightning-fast-by-compressing-deflategzip-your-html-javascript-css-xml-etc-in-apache/.

提交回复
热议问题