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

MWPW-158071: Optimize LCP loading times #2914

Merged
merged 6 commits into from
Sep 24, 2024

Conversation

mokimo
Copy link
Contributor

@mokimo mokimo commented Sep 19, 2024

Description

It's relatively hard to track performance beforehand, however we observed a +500MS (13%) gain on CC pages speeding up loading placeholders. We've also seen good success with preloading

Decorate.js

This PR initially introduced the idea of preloading decorate.js for a performance gain, but introduced too much flexibility. The idea of preloading decorate.js for specifically the two common (hero-)marquees blocks is valuable and worth the added 3 lines of code, as neither is likely to change anytime soon.

Impressions

This should provide good benefits on a wide arrange of blocks, consumers and pages by optimizing the load order and chains, however we will want to observe the CRUM/RUM/CRUX data after merging the changes in this PR.

Given the success we seen with preloading & parallelizing work in general, this harmonizes the timeline and ensures the browser loads everything as fast as it can, without any impact on TBT/CLS.

Before
Screenshot 2024-09-19 at 15 13 16
After
Screenshot 2024-09-19 at 15 13 24

Resolves: MWPW-158071

Test URLs:

Bacom

CC

@@ -731,6 +731,8 @@ function decorateDefaults(el) {
}

function decorateHeader() {
const breadcrumbs = document.querySelector('.breadcrumbs');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I noticed that if a breadcrumbs is authored as first block, we immediately load it. The global-navigation should take care of this and on L752 we move the breadcrumbs into the header if (breadcrumbs) header.append(breadcrumbs);

Copy link
Contributor Author

@mokimo mokimo Sep 19, 2024

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

@mokimo where are you seeing that we immediately load this? For me it looks like it was already working properly before any change here. 😅

Copy link
Contributor Author

@mokimo mokimo Sep 23, 2024

Choose a reason for hiding this comment

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

Here's a test experience @vhargrave https://main--milo--adobecom.aem.page/drafts/osahin/education

When you turn the header off, it treats the breadcrumbs as block, which 404s. PS: I noticed my comment might have been a bit misleading, the issue is that we try to load it as a block, but if there is no header - there is no breadcrumbs, so we should remove it to safeguard authoring mistakes.

Copy link
Contributor

Choose a reason for hiding this comment

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

ah ok, i see thanks 👍

Copy link

codecov bot commented Sep 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (stage@accd362). Learn more about missing BASE report.
Report is 22 commits behind head on stage.

Additional details and impacted files
@@           Coverage Diff            @@
##             stage    #2914   +/-   ##
========================================
  Coverage         ?   96.27%           
========================================
  Files            ?      238           
  Lines            ?    54527           
  Branches         ?        0           
========================================
  Hits             ?    52497           
  Misses           ?     2030           
  Partials         ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mokimo
Copy link
Contributor Author

mokimo commented Sep 19, 2024

nala tests also failing on stage: #2910

Copy link
Contributor

@JasonHowellSlavin JasonHowellSlavin left a comment

Choose a reason for hiding this comment

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

Looks good. Are there any unit tests for utils that require updating?

Copy link
Contributor

This pull request is not passing all required checks. Please see this discussion for information on how to get all checks passing. Inconsistent checks can be manually retried. If a test absolutely can not pass for a good reason, please add a comment with an explanation to the PR.

Copy link
Contributor

@robert-bogos robert-bogos left a comment

Choose a reason for hiding this comment

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

Looks good 👍
Maybe we can get the psi check to also pass.

libs/utils/utils.js Outdated Show resolved Hide resolved
libs/utils/utils.js Outdated Show resolved Hide resolved
Copy link
Contributor

aem-code-sync bot commented Sep 23, 2024

Page Scores Audits Google
📱 /?martech=off PERFORMANCE A11Y SEO BEST PRACTICES SI FCP LCP TBT CLS PSI
🖥️ /?martech=off PERFORMANCE A11Y SEO BEST PRACTICES SI FCP LCP TBT CLS PSI

@mokimo
Copy link
Contributor Author

mokimo commented Sep 23, 2024

@JasonHowellSlavin I've added a unit test covering the new behavior, other than that the old ones should continue working as is

Copy link
Contributor

@vhargrave vhargrave left a comment

Choose a reason for hiding this comment

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

looking pretty good!

libs/utils/utils.js Show resolved Hide resolved
libs/utils/utils.js Outdated Show resolved Hide resolved
Copy link
Contributor

@overmyheadandbody overmyheadandbody left a comment

Choose a reason for hiding this comment

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

Glad you managed to avoid calling the placeholder logic multiple times. This is worth trying out; in the future, we might want to get data on additional blocks that might be used as LCP and expand the current marquee list.

Copy link
Contributor

@vhargrave vhargrave left a comment

Choose a reason for hiding this comment

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

looking good!
i think the loadLink method would be good to take a look at, but defnitely out of scope for your ticket.

@SilviuLCF SilviuLCF self-requested a review September 24, 2024 10:36
Copy link

@SilviuLCF SilviuLCF left a comment

Choose a reason for hiding this comment

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

Ready to stage , Regression PASS , testing details https://jira.corp.adobe.com/browse/MWPW-158913

@milo-pr-merge milo-pr-merge bot merged commit 75fa60c into adobecom:stage Sep 24, 2024
18 checks passed
@milo-pr-merge milo-pr-merge bot mentioned this pull request Sep 24, 2024
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.

8 participants