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

Dynamically import consented code #1397

Merged
merged 4 commits into from
Jun 5, 2024
Merged

Dynamically import consented code #1397

merged 4 commits into from
Jun 5, 2024

Conversation

Jakeii
Copy link
Member

@Jakeii Jakeii commented May 30, 2024

What does this change?

Dynamically import our consented code from the entrypoint as well as our consented code which is already dynamically imported.

Why?

This makes a small improvement to the amount of code transferred in our consentless environment.

The increase in the number of chunks may also help with performance as they can now load in parallel.

Before After
Consented 256kb transferred / 793kb parsed 259kb transferred (1.1% larger) / 794kb parsed
Consentless 130kb transferred / 414kb parsed 113kb transferred (11% smaller) / 350kb parsed

Copy link

changeset-bot bot commented May 30, 2024

🦋 Changeset detected

Latest commit: adc6650

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@guardian/commercial Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@Jakeii Jakeii added the [beta] @guardian/commercial Add this label to publish an @guardian/commercial beta npm release from a PR label May 30, 2024
Copy link
Contributor

🚀 0.0.0-beta-20240530094903 published to npm as a beta release

@Jakeii Jakeii changed the title Fully split consented and consentless code Dynamically import consented code May 30, 2024
@Jakeii Jakeii marked this pull request as ready for review May 30, 2024 12:46
@Jakeii Jakeii requested a review from a team as a code owner May 30, 2024 12:46
@Jakeii Jakeii added [beta] @guardian/commercial Add this label to publish an @guardian/commercial beta npm release from a PR and removed [beta] @guardian/commercial Add this label to publish an @guardian/commercial beta npm release from a PR labels May 30, 2024
Copy link
Contributor

🚀 0.0.0-beta-20240530130323 published to npm as a beta release

@@ -21,16 +34,9 @@ const chooseAdvertisingTag = async () => {
'./init/consentless'
).then(({ bootConsentless }) => bootConsentless(consentState));
} else {
bootCommercialWhenReady();
void import(
/* webpackChunkName: "consented" */
Copy link
Member

Choose a reason for hiding this comment

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

Whilst this may decrease the size of the bundles it could introduce a delay to commercial-start for consented as we are introducing a waterfall loading process. I think its worth measuring or running as an ab-test.

Copy link
Member Author

Choose a reason for hiding this comment

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

We will be monitoring our commercial metrics of course to do pre/post analysis, an ab test is likely to be produce clearer results although with the complexity of serving different bundles?

Copy link
Member

@arelra arelra May 30, 2024

Choose a reason for hiding this comment

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

Okay great as long we are tracking the impact to commercial-start for consented. It will be interesting to see if there is any impact to mobile devices which are usually more network constrained.

Copy link
Contributor

@deedeeh deedeeh left a comment

Choose a reason for hiding this comment

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

The code looks good and thank you @Jakeii for answering my questions in DM!

I can see from the chat on the PR we will merge that change and keep an eye on the commercial-start metric for consented but is there any further testing that could be done before we merge?

@Jakeii Jakeii mentioned this pull request Jun 3, 2024
@Jakeii
Copy link
Member Author

Jakeii commented Jun 4, 2024

The code looks good and thank you @Jakeii for answering my questions in DM!

I can see from the chat on the PR we will merge that change and keep an eye on the commercial-start metric for consented but is there any further testing that could be done before we merge?

Maybe this would build more confidence? #1401 (comment)

@deedeeh
Copy link
Contributor

deedeeh commented Jun 4, 2024

The code looks good and thank you @Jakeii for answering my questions in DM!
I can see from the chat on the PR we will merge that change and keep an eye on the commercial-start metric for consented but is there any further testing that could be done before we merge?

Maybe this would build more confidence? #1401 (comment)

Yes, definitely that would make things better. I assume the PR you shared is going to be merged before this one so we can see the outcome. Correct?

Copy link
Contributor

github-actions bot commented Jun 4, 2024

Ad load time test results

For consented, top-above-nav took on average 4862.5ms to load.
For consentless, top-above-nav took on average 2882.15ms to load.

Test conditions:

  • 5mbps download speed
  • 1.5mbps upload speed
  • 150ms latency

Copy link
Contributor

@deedeeh deedeeh left a comment

Choose a reason for hiding this comment

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

Looks great Jake! You already answered my last question regarding merging the benchmarking PR before this one.

@Jakeii Jakeii merged commit 15fdb02 into main Jun 5, 2024
11 checks passed
@Jakeii Jakeii deleted the jlk/chunk-consented branch June 5, 2024 11:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[beta] @guardian/commercial Add this label to publish an @guardian/commercial beta npm release from a PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants