首页 » 最新资讯 » Google Amp目前已支持自定义js脚本

Google Amp目前已支持自定义js脚本

谷歌已收录,更新于2019年08月25日; 如遇到问题,请留言及时通知站长; 欢迎加入 三生三世,讨论各种问题!

谷歌在821号,宣布通过amp-script可以将自定义JavaScript添加到AMP页面,这对于我们来说无疑是个好消息。AMP团队表示,这是使用AMP的开发人员最需要的功能之一。它使通过AMP提供的网页能够包含JavaScript提供的更多交互功能。该amp-script组件在单独的Worker线程中运行页面的自定义JavaScript。在此更新之前,AMP页面大部分是静态的,这限制了它的使用,并迫使发布者在移动搜索结果中为速度和可能的可见性而牺牲功能。

amp-script

今年早些时候在AMP Conf上,谷歌给我们介绍了<amp-script>的开发者预览版。现在,谷歌宣布了<amp-script>的普遍可用性。它是一个AMP组件,在单独的Worker线程中运行您自己的JavaScript。这使您可以将自定义JavaScript添加到AMP页面,同时仍保持其闪电般的速度!

谷歌AMP页面

<amp-script>可让您涵盖现有AMP组件无法使用的用例。它还允许您在AMP和非AMP页面之间共享代码。您甚至可以使用JavaScript框架。以下是<amp-script>团队正在构建的一些示例:

  • Todo MVC使用Vue
  • 密码检查器,
  • 使用D3.js在文章中进行数据可视化,
  • 多页表单,其中每个部分都需要验证才能进入下一部分,下方是具体的效果演示。

多页表单

如何使用

如果以上示例对您感兴趣,请尝试使用<amp-script>。请记住,为了保持AMP的性能保证,存在一些限制:

  • 内容跳转:为了避免意外的内容跳跃,<amp-script>通常需要用户手势来更改页面内容。
  • 页面加载:由于<amp-script>在没有用户交互的情况下不会更改页面内容,因此它也不会在页面加载时修改内容。
  • 脚本大小:单个<amp-script>中使用的脚本必须小于150kB。请注意,欢迎您使用自己喜欢的JS框架,但它必须符合150K的限制。
  • API支持:并非所有API都支持Web Worker,而WorkerDOM具有允许的API列表。此外,尚未实现某些DOM方法和属性。完整列表可在WorkerDOM兼容性中公开获得。如果您要添加API,请提出问题

<amp-script>与您可能已经使用的框架兼容,例如ReactPreactAngularVue.jsjQueryD3.js.

这是开发人员使用AMP的最重要请求之一。AMP项目很高兴我们可以帮助解决这个问题,同时仍然保留AMP的速度价值主张。您可以在此处了解有关<amp-script>如何工作的更多信息,并按照本指南试用<amp-script>。这是解锁之前无法实现的大量用例的好方法!

后续说明

最后,如果你有任何关于使用<amp-script>时的疑问,可以前往amp论坛参与讨论。

这里给各位提供各种谷歌工具教程资源,希望给你一个安稳的家。

发表评论

仅有一条评论

  1. Eric Jones Eric Jones说道:

    Hey, this is Eric and I ran across googlecho.com a few minutes ago.

    Looks great… but now what?

    By that I mean, when someone like me finds your website – either through Search or just bouncing around – what happens next? Do you get a lot of leads from your site, or at least enough to make you happy?

    Honestly, most business websites fall a bit short when it comes to generating paying customers. Studies show that 70% of a site’s visitors disappear and are gone forever after just a moment.

    Here’s an idea…

    How about making it really EASY for every visitor who shows up to get a personal phone call you as soon as they hit your site…

    You can –

    Talk With Web Visitor is a software widget that’s works on your site, ready to capture any visitor’s Name, Email address and Phone Number. It signals you the moment they let you know they’re interested – so that you can talk to that lead while they’re literally looking over your site.

    CLICK HERE http://www.talkwithwebvisitor.com to try out a Live Demo with Talk With Web Visitor now to see exactly how it works.

    You’ll be amazed - the difference between contacting someone within 5 minutes versus a half-hour or more later could increase your results 100-fold.

    It gets even better… once you’ve captured their phone number, with our new SMS Text With Lead feature, you can automatically start a text (SMS) conversation.

    That way, even if you don’t close a deal right away, you can follow up with text messages for new offers, content links, even just “how you doing?” notes to build a relationship.

    Pretty sweet – AND effective.

    CLICK HERE http://www.talkwithwebvisitor.com to discover what Talk With Web Visitor can do for your business.

    You could be converting up to 100X more leads today!

    Eric
    PS: Talk With Web Visitor offers a FREE 14 days trial – and it even includes International Long Distance Calling.
    You have customers waiting to talk with you right now… don’t keep them waiting.
    CLICK HERE http://www.talkwithwebvisitor.com to try Talk With Web Visitor now.

    If you'd like to unsubscribe click here http://talkwithwebvisitor.com/unsubscribe.aspx?d=googlecho.com

返回主页看更多
赏杯咖啡给站长 支付宝 扫一扫