2

I cannot get the AMP validation when using Trust Pilot custom script, with the error: Custom JavaScript is not allowed. AMP doesn't allow custom script.

I need to add <script type="text/javascript" src="//widget.trustpilot.com/bootstrap/v5/tp.widget.bootstrap.min.js" defer></script> for the trust pilot review to work. How can I get this custom script to work with AMP? Thanks

UPDATED:

I found a workaround (well, if it finally works), however, I run into another issue. I put the Trustpilot script and widget to a separate file then on my AMP page, I would use amp-iframe to place it on the page. AMP would validate but Iframe is not rendering with the following error message: Origin of <amp-iframe> must not be equal to container. I have tried a few solutions on here but nothing worked so far.

<amp-iframe width="275" height="380"
  resizable
  sandbox="allow-scripts allow-same-origin"
  layout="responsive"
  frameborder="0"
  src="/trustpilot">
<div overflow tabindex=0 role=button aria-label="Read more">Read more!</div>
</amp-iframe>
Victoria Le
  • 860
  • 6
  • 15

1 Answers1

0

You can’t. That’s the point. The proliferation of external scripts like TrustPilot into websites is why the modern web is slower than it should be.

AMP isn’t fast just because of better CDN caching closer to your visitors. It’s also fast because AMP disallows web-dev practices that slow down the web. Things like external scripts (user-tracking, “analytics”, ad networks, etc), certain external content like beacons, sites that blindly include megabyte-sized CSS files full of unused style rules, and so on.

Dai
  • 141,631
  • 28
  • 261
  • 374