【问题标题】:How to add (Trust Pilot) Custom Script to an AMP page如何将(Trust Pilot)自定义脚本添加到 AMP 页面
【发布时间】:2019-07-13 03:15:41
【问题描述】:

使用 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】:

你不能。 这就是重点。像 TrustPilot 这样的外部脚本在网站中的扩散是现代网络比应有的速度慢的原因。

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

【讨论】:

    猜你喜欢
    • 2019-04-25
    • 2021-04-29
    • 2011-05-20
    • 2021-10-13
    • 2019-10-29
    • 2020-06-08
    • 2019-08-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多