如何将(Trust Pilot)自定义脚本添加到AMP页面

问题描述 投票:1回答:1

使用Trust Pilot自定义脚本时,我无法获得AMP验证,错误:Custom JavaScript is not allowed。 AMP不允许自定义脚本。

我需要添加<script type="text/javascript" src="//widget.trustpilot.com/bootstrap/v5/tp.widget.bootstrap.min.js" defer></script>以便信任试点审查工作。如何让这个自定义脚本与AMP一起使用?谢谢

更新:

我找到了一个解决方法(好吧,如果它最终有效),但是,我遇到了另一个问题。我把Trustpilot脚本和小部件放到一个单独的文件然后在我的AMP页面上,我会使用amp-iframe将它放在页面上。 AMP将验证,但Iframe未呈现以下错误消息:Origin of <amp-iframe> must not be equal to container。我在这里尝试了一些解决方案但到目前为止没有任何工作。

<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>
javascript html amp-html trustpilot
1个回答
0
投票

你不能。这才是重点。像TrustPilot这样的外部脚本扩散到网站中是现代网络比它应该更慢的原因。

AMP并不快,只是因为更接近访问者的CDN缓存更好。它也很快,因为AMP不允许网络开发实践减慢网络速度。诸如外部脚本(用户跟踪,“分析”,广告网络等),某些外部内容(如信标),盲目包含兆字节大小的CSS文件以及未使用的样式规则的网站等等。

© www.soinside.com 2019 - 2024. All rights reserved.