- Todo MVC using Vue,
- A password checker,
- Data visualization in an article using D3.js,
- Multi-page forms where each section needs validation before proceeding to the next section as seen below.
If the above examples interest you, do give <amp-script> a try. Do keep in mind that, in order to preserve AMP’s performance guarantee, there are some constraints:
- Content jumping: To avoid unexpected content jumping, <amp-script> generally requires user gestures to change page content.
- Page load: Since <amp-script> doesn’t change page content without user interaction, it doesn’t modify content on page load either.
- Script size: The script used in a single <amp-script> must be smaller than 150kB. Please note that you’re welcome to use your favorite JS framework, but it must fit within that 150K limit.
- API support: Not all APIs are supported inside a Web Worker and WorkerDOM has a list of allowed APIs. In addition, some DOM methods and properties are not yet implemented. The full list is available publicly in WorkerDOM compatibility. Please file an issue if there is an API that you want to see added.
<amp-script> is compatible with frameworks you may already be using such as React, Preact, Angular, Vue.js, jQuery and D3.js.
This was one of the most important requests from developers using AMP. AMP Project is excited that we could help address this while still retaining AMP’s value proposition of speed. You can learn more about how <amp-script> works under the hood here and try out <amp-script> by following this guide. It’s a great way of unlocking a large number of use cases that weren’t possible before!
Please let us know if you have any issues or feature requests, when using <amp-script>.
Posted by Naina Raisinghani, Product Manager, AMP Project at Google