Please help me understand how to add javascript in the AMP (Accelerated Mobile Pages). My requirement is I get an ID in URL. For example localhost:8080/home?id=1.I would lik
As of 11th of April 2019 Official Announcement,
it is now possible using your JS inside an AMP project with amp-script component.
First you need to import it to your project:
.html file import:
html element/s with the amp-script component:
// hello-world.js
const button = document.getElementById('hello');
button.addEventListener('click', () => {
const el = document.createElement('h1');
el.textContent = 'Hello World!';
// `document.body` is effectively the element.
document.body.appendChild(el);
});
You can find more details and how it works in the AMP git repo amp-script.md