Mechanism for loading new extensions in <amp-live-list>
See original GitHub issueProblem
amp-live-list supports adding new content to an already loaded document, via polling for updates to the origin or cache.
New content can potentially include custom elements which were not in the original document. This presents a problem because amp-live-list does not specify a mechanism for loading new script tags into the document head, only for modifying content in the document body. The server side filtering rules even specify that the new content can strip out the head section in the response for efficiency. This filtering is implemented by the AMP cache.
The current recommended workaround is that documents using <amp-live-list>
include the superset of all possible custom elements which may be loaded in the future. This solution is unfortunately likely to result in pages loading far more javascript than is necessary.
Proposal
<amp-live-list>
documents should always specify the set of custom elements required for loading the current document content (and ideally no others) just like any other AMP document. In the server side filtered case, documents should include a small <head>
section containing the custom elements used by the filtered content. For example:
<!doctype html>
<html ⚡>
<head>
<script async custom-element="amp-twitter" src="https://cdn.ampproject.org/v0/amp-twitter-0.1.js"></script>
</head>
<body>
<amp-live-list id="live-list-1" data-max-items-per-page="10">
<div items>
<amp-twitter id="item-3"
data-update-time="1462955848173"
data-sort-time="1462955848173"></amp-twitter>
</div>
</amp-live-list>
</body>
</html>
The amp-live-list
custom-element javascript will need to extract the script tags from the head section and load any new custom-elements which haven’t yet been loaded before rendering the content.
Issue Analytics
- State:
- Created 7 years ago
- Comments:13 (10 by maintainers)
@aghassemi @camelburrito i already have the code for this here https://github.com/ampproject/amphtml/pull/9302/files
just need to add tests which I’ll do after doing release today
Closing this, as I think it’s launched, but @erwinmombay , let me know if there are any bits that aren’t done yet