how to gzip compress CSS and JS
See original GitHub issueI tried to find a way to compress files and version them but couldn’t find a way to do this.
Basically, I want to do something like this,
mix.compress(['path/to/file1.css', 'path/to/file2.js'], 'destination/path/');
Result:
'destination/path/file1.css.gz'
'destination/path/file2.js.gz'
Could someone please point me in the right direction? Thanks!
PS Thank you so much for your awesome work @JeffreyWay
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:8 (2 by maintainers)
Top Results From Across the Web
How can I gzip my JavaScript and CSS files? - Stack Overflow
Restart the nginx with command /etc/init.d/nginx reload . It will compress the JS and CSS files. Share.
Read more >The Difference Between Minification and Gzipping | CSS-Tricks
Gzipping is far more effective. Doing both is ideal. ... Gzipping reduces the file size about five times as much as minifying does....
Read more >How to activate Gzip Compression CSS and JS for better ...
Step 1: Enable gzip for PHP · Step2: Create a PHP Compressor · Step 3: Redirect requests for CSS and JavaScript to PHP....
Read more >How to Enable GZIP Compression for Faster Web Pages
GZIP is the current standard for file compression on the web. ... This will compress all HTML, CSS, JavaScript, XML, and font files....
Read more >How to manually gzip CSS and JS files and serve them with ...
How to manually gzip CSS and JS files and serve them with Apache ... They will be compressed into new files with a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@mrajabtech Most modern web servers has ability to serve gzip content on the fly. Apache has
mod_gzip
and mod_deflate while nginx can also do that.We should not serve
*.gz
content unless browser request for it, and web-servers can take care of that automatically.Is there any other good reason that Laravel Mix should generate
*.gz
files ?@ankurk91 Reason is simple: if you have 1000 requests to *.js file with gzip enabled, it will be compressed by nginx 1000 times. Same file with exactly same output. if we have *.js.gz file and gzip_static enabled, nginx will just output that file to user. It not only saves CPU (and you can rent less powerful servers and pay less), but also significantly reduces TTFB (Time to first byte) - user doesn’t wait for compression to complete.
I used this:
webpack.mix.js
and it works well for .js & .css files, but it ignores, for example, .svg files, copied from resources to public folder. Any Idea, how to gzip them?