Asked 8 years ago
24 Oct 2016
Views 975
sandip

sandip posted

How to do gzip compress for javascript/css on fly in php ?

i am checking my website's page speed by google PageSpeed Insights , and i found error there

Enable compression
gzip compression for all CSS/JS file requests


so How to do gzip compress js/css on fly in php ? or any supported compress with web server should be used to compress javascript/css on fly in php
so let me know if any way we can compress javascript or css on fly in php
Mitul Dabhi

Mitul Dabhi
answered Nov 30 '-1 00:00

1. you can start automatic compression by server which apply to all website resource like text , content , Css , JavaScript
ask web hosting provider to enable one of the compression based on the server . see detail
WebServerSupported Compression
Apache: mod_deflate
Nginx: ngx_http_gzip_module
IIS: Configure HTTP Compression



find your server nature . try to make enable suitable compression

Rasi

Rasi
answered Nov 30 '-1 00:00

https://github.com/archirayan-infotech/JSMin


$data= file_get_contents("bootstrap.js");
include("Jsmin.php");
$minified=JSMin::minify($data);
Post Answer