How can I gzip my JavaScript and CSS files?

后端 未结 6 1084
独厮守ぢ
独厮守ぢ 2021-02-05 07:52

I have a problem, I have to gzip a prototype Lib, but i totaly have no idea how to do this, where to start and how does it works. :)

I find some tutorials but that wasn\

6条回答
  •  臣服心动
    2021-02-05 08:02

    You can use apache's mod_deflate to automatically compress your files on the fly.

    Example:

    AddOutputFilterByType DEFLATE text/html text/xml text/css text/javascript 
    

    [edit]

    To check if your apache server has already output compression enabled, put the example above into an .htaccess file. Then load an html or js file via the server and check the headers for "Content-Encoding", if it says gzip or deflate, it is enabled.

提交回复
热议问题