Skip to content

Latest commit

 

History

History
48 lines (30 loc) · 1.72 KB

amp-install-serviceworker.md

File metadata and controls

48 lines (30 loc) · 1.72 KB

amp-install-serviceworker

The amp-install-serviceworker component allows installing a ServiceWorker for the current page.

The idea here is that this ServiceWorker runs whenever the AMP file is served from the origin where you publish the AMP file. The ServiceWorker will not be loaded when the document is loaded from an AMP cache.

See this article for how ServiceWorkers can help with making the AMP experience awesome with ServiceWorkers.

Example

  <amp-install-serviceworker
      src="https://www.your-domain.com/serviceworker.js"
      layout="nodisplay"
  </amp-install-serviceworker>

Behavior

Registers the ServiceWorker given by the src attribute. If the current origin is different from the origin of the ServiceWorker, this custom element does nothing (Emits warning in development mode).

Attributes

src

URL of the ServiceWorker to register.

layout

Must have the value nodisplay.