Skip to content

[amp-script] Support inline JS #22612

@sebastianbenz

Description

@sebastianbenz

Not sure if this came up already (at least I couldn't find anything): it looks like amp-script currently only supports embedding external JS via the src attribute. It'd be great to be able to define custom scripts inline:

 <amp-script layout=container src="/examples/amp-script/hello-world.js">
    <button id="greeting">Say hello</button>
    <script>
    const button = document.getElementById('greeting')
    ...
    </script>
  </amp-script>

I see a few advantages for this:

  1. This would greatly simplify documenting amp-script as samples would no longer need two files.
  2. Faster loading time (we probably should restrict script size for these cases even further).

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions