简体   繁体   中英

Compress JavaScript with gzip

I ran Google PageSpeed Insights to optimize my site and it recommended archiving the numerous JavaScript files with gzip.

How does this work? How are the files imported/included as an archive? Can they all be inside one big archive, or should they be individual archives?

I think they were referring to having static content compressed by the web server. The files themselves are the same, but you may need to do some configuration with whatever web server you have.

See this for more info.

You can configure your web server to do the compression for you; in the case of Apache :

AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript

Most web servers (Apache, IIS, Node) support this feature internally or with plugins. You usually just have to enable it on the web server, you don't actually create the zip files or change anything manually. Take a look at http://betterexplained.com/articles/how-to-optimize-your-site-with-gzip-compression/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM