You can now add custom JavaScript to AMP pages

Custom JavaScript can now be added to AMP pages, Google announced this week. The amp-script component can be used to enable user interactions, and to share code across AMP-enabled and non-AMP pages.

JavaScript features, such as multi-page forms that need to be validated before moving on to the next section, can now be delivered via AMP. Source: Google.

Why we should care

The AMP team said this was one of the most requested features from developers using AMP. It enables web pages delivered via AMP to incorporate more of the interactivity features that JavaScript offers.

The amp-script component runs a page’s custom JavaScript in a separate Worker thread.

Prior to this update, AMP pages have been mostly static, which limited its uses and forced publishers to compromise features for speed and potentially visibility in mobile search results.

More on the news

  • The new amp-script component is compatible with React, Preact, Angular, Vue.js, jQuery and D3.js frameworks.
  • amp-script doesn’t change page content without user interaction, so it won’t modify your content upon page load.
  • The script within a single amp-script must be less than 150kB.
  • Not all APIs are supported inside a Web Worker; refer to WorkerDOM’s list of allowed APIs.

About The Author

George Nguyen is an Associate Editor at Third Door Media. His background is in content marketing, journalism, and storytelling.

Dit artikel is vertaald van Search Engine Land

Blog onderwerpen

smoop logo wit

Over Smoop

Smoop helpt sinds 2011 kleine en middelgrote bedrijven met de online vindbaarheid. Smoop denkt mee op strategisch niveau om maximale resultaten uit het marketingbudget te halen.

Wil je een (snellere) omzetgroei met jouw bedrijf? Neem dan direct contact op.

Contact

Kantoor & Bezoek:

Smoop
Wijnhaven 6
2511 GA
Den Haag

Postadres:

Noord-West Buitensingel 5E
2518 PA
Den Haag

Copyright 2011 - 2020 ©  SMOOP

Chat openen
Stel hier vrijblijvend je vraag
Hallo,
Hoe kunnen we je helpen?