I read all documentation about script tag but I cannot find how to include a custom JavaScript in AMP HTML.
I know the <script>
tag is prohibited unless its type is application/ld+json
.
There are default AMP HTML runtime components and extended components which contain specific form for different components, but I could not find a specific one for custom JavaScript.
Here is the script tag I want to include in AMP HTML;
<script src="https://arifkarim.com/widget/layouts/global/js/legaltext.js"></script>
The whole point of AMP is to only allow a subset of web technologies to stop your page being slow.
Javascript is often the cause of slow websites and so AMP pages do not allow them (except for the AMP scripts themselves), though they've tried to fill in the gap this leaves with amp components which are specially written to not be slow.
So if you want to use Javascript you've several choices:
<script>
tags are generally not allowed in AMP. There are a handful of external javascript files, built as part of the AMP project, which are allowed and even required in some cases. Other than those, javascript is not allowed. Custom script tags are not possible with AMP.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With