最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Google AMP script conflicts with jquery window.scroll - Stack Overflow

programmeradmin1浏览0评论

I'm trying to follow the AMP guidelines suggested by Google (ampproject) but as soon as I add their js script, the jQuery scroll stops working

Does anybody knows why and how to fix it?

I'm trying to follow the AMP guidelines suggested by Google (ampproject) but as soon as I add their js script, the jQuery scroll stops working

Does anybody knows why and how to fix it?

Share Improve this question edited Jun 9, 2016 at 7:19 Allen Fernandes 1,35311 silver badges18 bronze badges asked Feb 4, 2016 at 19:11 FrancescoFrancesco 25.3k32 gold badges108 silver badges159 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 5

The script tag is prohibited in AMP HTML unless:

  • The type is application/ld+json
  • It is the mandatory script tag to load the AMP runtime
  • It is a tag to load extended ponents

https://github./ampproject/amphtml/blob/master/spec/amp-html-format.md#html-tags

A list of available extensions, such as amp-carousel, can be found here.

You can also use custom elements and web ponents according to this page.

"AMP ponents may have JavaScript under the hood, but it is coordinated with other AMP ponents, so its position into the page doesn’t cause performance degradation."

The only way to include JQuery scroll is to pull it in via an AMP-IFRAME tag. But that will only give you access to it within the context of the amp-iframe so most likely that will not help you. What are you trying to acplish with the JQuery scroll? AMP pages are meant to be simple and for displaying information very quickly. Best examples for the use of AMP pages are news sites. If you open CHROME debugger and click on the mobile view icon and then do a search for say "Trump", you'll see the carousel of AMP pages at the top. You'll notice that they are all simple news stories. Nothing to fancy.

Do you have an example of what you are trying to do that we can look at?

发布评论

评论列表(0)

  1. 暂无评论