0

I'm confused how AMP supports author written javascript. I learned from the doc that AMP disable author written javascript, but why does it work when I directly insert javascript code in tag? simple as the code below works fine on AMP page. Other code like I'm inserting a snippet of javascript code in tag to load a service works fine too. Thanks.

​<script>
   alert("hi");
</script>
Xiao
  • 59
  • 6

1 Answers1

0

This means that you are only permitted to use the JavaScript library that AMP provides – since you’re not in control, you may experience lazy loading. This might be the only downside to AMP. Therefore, you can't use custom JS. It has this open proposed design for this issue. You can also probably check AMP HTML Specification for more details about the supported tags.

Jessica Rodriguez
  • 2,899
  • 1
  • 12
  • 27
  • Thanks for your answer jess. Am I understanding it right that as long as the js code asnyc, it won't cause any problem? Is "the JavaScript library that AMP provides" the AMP custom elements AMP provide [here](https://amp.dev/documentation/components/)? Thanks! – Xiao May 01 '19 at 21:39
  • I mean, how do I know which scripts AMP support and which not? Or should I just not use script? Thanks! – Xiao May 01 '19 at 21:58
  • Kindly check the documentation I have shared. You could see Required markup list. – Jessica Rodriguez May 02 '19 at 07:53
  • Thanks for the answer. – Xiao May 03 '19 at 23:15