Mobile app version of vmapp.org
Login or Join
Goswami781

: For chartjs versus AMP On my WordPress blog in default mode I have a <canvas> where I draw a chart with ChartJS. I've just downloaded the AMP plugin, run the Google AMP Test tool,

@Goswami781

Posted in: #Amp #Canvas #Javascript

On my WordPress blog in default mode I have a <canvas> where I draw a chart with ChartJS. I've just downloaded the AMP plugin, run the Google AMP Test tool, and it says:


Fix the following issue
Prohibited or invalid use of HTML Tag
The tag 'canvas' is disallowed.


How do you go about fixing this? Is there any way to do JavaScript with AMP?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Goswami781

1 Comments

Sorted by latest first Latest Oldest Best

 

@Smith883

You can't run your own JavaScript when using AMP, that defeats the purpose of AMP. Instead, you can iframe your external content using the amp-iframe element.


Add the amp-iframe JS to the head.



<script async custom-element="amp-iframe"
src="https://cdn.ampproject.org/v0/amp-iframe-0.1.js"></script>

Add the amp-iframe element where you want your iframe to go.

<amp-iframe width="200" height="100"
sandbox="allow-scripts allow-same-origin" layout="responsive"
src="https://example.com/"></amp-iframe>



A full guide to using amp-iframe is available at:

www.ampproject.org/docs/guides/iframes

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme