Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compress required external js files

I am using Gtmetrix to test my page load time. I enabled gzip compression on my site by adding code to .htaccess

.htaccess code:

<ifModule mod_gzip.c>

mod_gzip_on Yes

mod_gzip_dechunk Yes

mod_gzip_item_include file .(html?|txt|css|js|php|pl)$

mod_gzip_item_include handler ^cgi-script$

mod_gzip_item_include mime ^text/.*

mod_gzip_item_include mime ^application/x-javascript.*

mod_gzip_item_exclude mime ^image/.*

mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*

</ifModule>

but still Gtmetrix showing the below warning

Compressing http://s3.amazonaws.com/downloads.mailchimp.com/js/signup-forms/popup/embed.js could save 453.6KiB (71% reduction). This is an external js file. How can I compress this?

like image 511
m9m9m Avatar asked Mar 12 '23 19:03

m9m9m


1 Answers

Since browser requests for that file do not pass through your web server but rather go directly to s3.amazonaws.com, the short answer is: you can't.

However, you could download the file and put it on your web server and change the corresponding references in your HTML to load it from your site instead of from s3.amazonaws.com.

There is no reason why the file is not available in compressed format from Mailchimp but since they have not done so, you will need to serve it from your webserver to achieve compression.

like image 149
Brian Ghidinelli Avatar answered Mar 16 '23 03:03

Brian Ghidinelli