Search code examples
wordpressiframepagespeedpagespeed-insights

How to enable text compression on Amazon Affiliate iframes?


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:

enter image description here

and this is how they look like (as typical Amazon affiliates iframe):

enter image description here

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:

enter image description here

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).


Solution

  • 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

    <iframe 
    loading = "lazy"
    style="width:120px;
    height:240px;" 
    marginwidth="0" 
    marginheight="0" 
    scrolling="no" 
    frameborder="0" 
    src= {amazon link}>
    </iframe>