Search code examples
javascriptwordpressamp-html

Adding custom js files in AMP html?


I want to add custom javascript plugins, like owl-carousel in my AMP pages is it possible to do so?


Solution

  • You can not insert an external javascript in AMP because AMP does not javascript. But using amp-iframe you can create the functionality in the iframe and include that iframe in AMP page.

    So if you want to display images using owl-carousel, make an iframe in which you have implemented image carousel using owl-carousel and include that iframe in your AMP page. So it will look like it is on AMP page only. So iframe will contain image tag with owl-carousel.

    However, if you want to display images in the carousel in AMP pages, visit https://www.ampproject.org/docs/reference/components/amp-carousel This will help you anyway to implement image carousel in AMP.

    If you specify your requirements then I can help you to design your iframe or amp-carousel, whichever is possible.