Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Discussion: Creating a light version of the runtime for transformed documents #17

Open
sparhami opened this issue Aug 21, 2019 · 1 comment
Assignees

Comments

@sparhami
Copy link

When using the AMP toolbox optimizer, we should be able to tell when certain parts of the runtime are not necessary for a given page. We could consider making a lightweight runtime with a smaller set of code that handles a large percentage of pages, and a full one including all the features.

One example of feature not often needed for transformed pages is the client-side static layout logic (applyStaticLayout) in layout.js along with the corresponding CSS in ampshared.css. Another example is some CSS needed for amp-accordion in ampshared.css.

This would need to be included for anything doing client-side rendering (amp-list, amp-mustache, amp-script), but may be omitted for some number of more simple pages.

Some things can also have a lightweight stub implementation in the lightweight version, without breaking the synchronous nature of their heavyweight implementations. For example, url-replacements-impl.js, viewer-impl.js, pull-to-refresh.js (only needed if in a viewer), font-stylesheet-timeout (only needed if using a custom font), document-submit (only needed if amp-form is present).

We could potentially create a variety of binaries, but I think to keep things simple, we could create just two variants. The criteria for which features to include/exclude from the light binary are not exactly clear, there is a trade-off between having more pages with the light binary vs having a smaller light binary.

Using source-map-explorer to get a sense of code size, combined with a survey of existing pages and what features are commonly used could be a good way to prioritize which features to include/exclude.

@kristoferbaxter
Copy link
Contributor

This is a great idea. Thank you for posting the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants