skip to Main Content

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

2

Answers


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

    # BEGIN GZIP
    <IfModule mod_filter.c>
            AddOutputFilterByType DEFLATE "application/atom+xml" 
                                          "application/javascript" 
                                          "application/json" 
                                          "application/ld+json" 
                                          "application/manifest+json" 
                                          "application/rdf+xml" 
                                          "application/rss+xml" 
                                          "application/schema+json" 
                                          "application/vnd.geo+json" 
                                          "application/vnd.ms-fontobject" 
                                          "application/x-font-ttf" 
                                          "application/x-javascript" 
                                          "application/x-web-app-manifest+json" 
                                          "application/xhtml+xml" 
                                          "application/xml" 
                                          "font/eot" 
                                          "font/opentype" 
                                          "image/bmp" 
                                          "image/svg+xml" 
                                          "image/vnd.microsoft.icon" 
                                          "image/x-icon" 
                                          "text/cache-manifest" 
                                          "text/css" 
                                          "text/html" 
                                          "text/javascript" 
                                          "text/plain" 
                                          "text/vcard" 
                                          "text/vnd.rim.location.xloc" 
                                          "text/vtt" 
                                          "text/x-component" 
                                          "text/x-cross-domain-policy" 
                                          "text/xml"
        
    </IfModule>
    # END GZIP
    
    Login or Signup to reply.
  2. 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>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search