How can I compress / gzip my mimified .js and .css files before publishing to AWS S3?

Question:

I ran Google pagespeed and it suggests compressing my .js and .css

Eliminate render-blocking JavaScript and CSS in above-the-fold content
Show how to fix

During my publish I have a step that uses Windows Powershell to move a .js and .css mimified bundle to S3 and this goes to cloudfront.

Is there some step I could add in the PowerShell script that would compress the .js and .css files?

Also once the files are compressed then do I have to do anything more than change the name so as to tell my browser that it will need to try and accept a gzip file?

Answer:

You can add to your upload script the needed code to gzip compress the files.

Some example code could be this:

From this site: Gzip creation in Powershell

Source:

How can I compress / gzip my mimified .js and .css files before publishing to AWS S3? by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply