![]() To fill this gap, the AMP team created an open-source library called WorkerDOM. Workers don't come with access to the DOM. Workers offer a path to a multithreaded Web, a way to encapsulate JavaScript in a sandbox where it can't block the UI. They can only communicate with the main thread and with one another via messages containing objects. Thus they can't interfere with each other's work or with mutations caused by code in the main thread. This is possible because they lack access to the DOM or the window object, and each worker runs in its own global scope. Normally all JavaScript runs in a single thread, but each worker runs in a thread of its own. Web workers present a way to run JavaScript more safely. In order to control what JavaScript AMP pages load and when it executes, AMP's validation rules forbid developers from running JavaScript in a webpage via a tag. ![]() Web workersĮxcessive JavaScript can make websites slow and unresponsive. This guide provides background on this component and best practices for its use. By using amp-script, you can embrace custom logic for specific use cases or unique needs without losing AMP's benefits. Most AMP components enable common web interactions through their own logic, letting you build your page quickly without writing JavaScript or importing third-party libraries. Guides & Tutorials Use custom JavaScript in AMP pagesĪmp-script lets you write and run your own JavaScript in a way that maintains AMP's performance guarantees.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |