Amazon Native Ads Trigger Issues In Lighthouse

Here is a snippet to use if you are receiving warnings regarding Accessibility and Best Practices when running a Lighthouse test in Chrome Dev (F12) related to in-page Amazon Ads.

  • Image elements have [alt] attributes
  • Links to cross-origin destinations are unsafe

Add the following code to the footer section of your page.

  function amzfix() {
    jQuery('.amzn-native-product-title').prop('rel', 'nofollow noopener sponsored');
    jQuery('div.amzn-native-product-title-container > a').attr('rel', 'nofollow noopener sponsored');
    jQuery('a.amzn-native-brand-link').attr('rel', 'nofollow noopener sponsored');
    jQuery('a.amzn-native-adchoices-link').attr('rel', 'nofollow noopener sponsored');
    //  Add required alt tags to amazon ad images for best practices
    jQuery('div.amzn-native-product-image-container > div > img:not([alt])').attr('alt', 'Amazon Product Image');

    //For testing
  	//let val = jQuery('div.amzn-native-product-title-container > a').attr('rel');


Available for Amazon Prime