AMP adds support for custom JavaScript

Web developers can now add custom JavaScript, including frameworks like React, to AMP pages using the new amp-script component.

A long-standing frustration for web developers has been the inability to use custom JavaScript (JS) with AMP pages. Without custom JS, web developers have been limited to the features provided by existing AMP components. It has also made it impossible for developers to incorporate popular JS frameworks, like React, Angular, and jQuery.

In response to an overwhelming amount of requests from developers, Naina Raisinghani, Product Manager for the AMP Project at Google, announced that web developers can now use the <amp-script> component to add custom JS to their AMP pages.

<amp-script> lets you cover use cases that you couldn’t with existing AMP components. It also lets you share code across your AMP and non-AMP pages.

Raisinghani did list some constraints to amp-script that are required to maintain AMP performance guarantees.

The addition of amp-script will enable more sites to integrate AMP and will also make it possible for other sites to convert their entire site over to AMP.

It’s important to note that AMP is a collection of web components that are focused on performance. It’s also designed to keep a site from degrading over time as changes are made by to it by different developers. It is still possible to create and maintain sites that are equally as fast as AMP but AMP offers a highly structured and strict framework for achieving that.