Skip to content

🚀 [Story performance] Install non-critical extensions in the document after the first page is loaded#37670

Merged
mszylkowski merged 20 commits intoampproject:mainfrom
mszylkowski:lateExtensions
Feb 16, 2022
Merged

🚀 [Story performance] Install non-critical extensions in the document after the first page is loaded#37670
mszylkowski merged 20 commits intoampproject:mainfrom
mszylkowski:lateExtensions

Conversation

@mszylkowski
Copy link
Copy Markdown
Contributor

@mszylkowski mszylkowski commented Feb 14, 2022

We want to test whether late installing non-critical (for LCP purposes) extensions can improve the loading times of stories.
The extensions that can be installed later and don't affect the rendering of the story are:

Part of #37680

@mszylkowski mszylkowski self-assigned this Feb 14, 2022
@amp-owners-bot
Copy link
Copy Markdown

amp-owners-bot bot commented Feb 14, 2022

Hey @gmajoulet, @newmuis! These files were changed:

extensions/amp-story/1.0/amp-story.js
extensions/amp-story/1.0/test/test-amp-story.js

Copy link
Copy Markdown
Contributor

@gmajoulet gmajoulet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have basic unit tests, at least one to verify that extensions are loaded with the correct heuristics, i.e. after the initial content is loaded?

@mszylkowski
Copy link
Copy Markdown
Contributor Author

@gmajoulet added unit tests to verify that the right elements install the scripts at the right time


const signals = new Signals();
pages[0].signals = () => signals;
story.buildCallback();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed

);

// Signal that the first page finished loading.
signals.signal(CommonSignals_Enum.LOAD_END);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need to call this manually, I see other tests doing things like

        await story.layoutCallback();
        await story.activePage_.element
          .signals()
          .whenSignal(CommonSignals_Enum.LOAD_END);

So maybe you could

        createStoryWithPages();
        append(amp-story-auto-ads);
        stub(installExtensionForDoc);

        await story.layoutCallback();
        await story.activePage_.element
          .signals()
          .whenSignal(CommonSignals_Enum.LOAD_END);

        expect(ampstoryautoads to be loaded);

mszylkowski and others added 2 commits February 16, 2022 11:56
Co-authored-by: Gabriel Majoulet <gmajoulet@google.com>
Copy link
Copy Markdown
Contributor

@gmajoulet gmajoulet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Plz open a ticket for a followup PR with more extensions that we can lazyload : ))

@mszylkowski mszylkowski merged commit 36b5cf2 into ampproject:main Feb 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants