AMP:Building Accelerated Mobile Pages
上QQ阅读APP看书,第一时间看更新

Using JavaScript in AMP pages

Let's deal with our first non-boilerplate error message:

The tag 'script' is disallowed except in specific forms.

In AMP, to guarantee performance, the use of JavaScript is greatly restricted. You can't write your own scripts, or include non-AMP JavaScript code. To fix this error, just remove the following line from your AMP document.

<script type="text/javascript" src="script.js"></script>

Don't worry, it's not needed. It was only included to demonstrate what the validator thinks of you including your own JavaScript!