How to add custom javascript or external js in AMP page?

一个人想着一个人 提交于 2019-12-08 06:24:21

问题


I have tried adding external js file in AMP page but AMP validator rejects it. Is there any workaround for it?


回答1:


AMP is a way to build fast rendering web page. In order to achieve this, AMP does not support external js. AMP have its own AMP JS library for more information CLICK HERE




回答2:


Actully now you have option to add custom javascript to a AMP page with <amp-script> component. https://amp.dev/documentation/guides-and-tutorials/develop/custom-javascript/




回答3:


There is a workaround using the amp-iframe component, but as mentioned in the previous answer, the whole idea of AMP is to build fast rendering pages without external JS, so I wouldn't recommend it.

Have a look at the AMP components currently supported by AMP and with one of them or with the combination of few of them, you will be able to replicate the features you are looking for.



来源:https://stackoverflow.com/questions/48390813/how-to-add-custom-javascript-or-external-js-in-amp-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!