I am trying to optimize a WordPress site that has some Amazon Affiliate iframes on it. Those iframes are those that you can get on the left corner of Amazon -> Obtain link -> Text + Image when you are on a specific product to obtain an affiliate link of it:
and this is how they look like (as typical Amazon affiliates iframe):
My question comes because when I run a test on PageSpeed, it shows me "Enable text compression" error that makes references to all the urls from the iframes:
My hosting have CPanel so I have enabled Text Compression on cPanel –> Optimize Website –> Mark "Compress All Content" option but it is still showing the error, so it doesnt seem it takes any effect on them.
Is there a way to optimize those iframes and enable text compression on them? It is a bit annoying that it takes so much time to load all of them (and they are between 15-20).
2
Answers
Since compression takes place on the server side it’s not possible to compress files hosted outside of your server and that is why you can’t serve the files from the Amazon iframe compressed. Also the iframes may cause problems with any caching on the website.
Maybe an alternative would be to create the product box yourself and then link them to the product using the affiliate link instead?
Old answer:
What version of apache are you running?
I belive if it’s above version 2 then you could try adding this to your root .htaccess.
Try it out and see if the compression takes any effect on the iframes.
You can add lazy load to your Iframe to increase page speed.
Refer this link to implement lazy load for iframes in WordPress
https://web.dev/iframe-lazy-loading/#wordpress