Skip to content

MWPW-170589: POC Loading Unity after LCP #1076

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

Open
wants to merge 6 commits into
base: stage
Choose a base branch
from
Open

Conversation

joaquinrivero
Copy link
Collaborator

@joaquinrivero joaquinrivero commented Mar 29, 2025

Description

This PR defers the loading of the Unity block and its libraries until after LCP event is completed. The goal is to reduce render-blocking resources during initial load and improve Core Web Vitals, specifically LCP

Screenshot 2025-04-15 at 10 28 36 AM

Related Issue

Resolves: MWPW-170589

Test URLs

Copy link

aem-code-sync bot commented Mar 29, 2025

Hello, I'm the AEM Code Sync Bot and I will run some actions to deploy your branch and validate page speed.
In case there are problems, just click a checkbox below to rerun the respective action.

  • Re-run PSI checks
  • Re-sync branch
Commits

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a proof-of-concept for loading the Unity block and its dependencies after the Largest Contentful Paint (LCP) event to optimize page performance.

  • Added a new function to create and load a Unity block within the verb widget.
  • Updated the analyticsLoad event listener to call the new function in both LCP and fallback branches.

@codecov-commenter
Copy link

codecov-commenter commented Mar 29, 2025

Codecov Report

Attention: Patch coverage is 1.35135% with 73 lines in your changes missing coverage. Please review.

Project coverage is 73.64%. Comparing base (ee9e9c5) to head (122d0c5).

Files with missing lines Patch % Lines
acrobat/blocks/verb-widget/verb-widget.js 1.40% 70 Missing ⚠️
acrobat/blocks/unity/unity.js 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##            stage    #1076      +/-   ##
==========================================
- Coverage   73.87%   73.64%   -0.23%     
==========================================
  Files          51       51              
  Lines        7732     7756      +24     
==========================================
  Hits         5712     5712              
- Misses       2020     2044      +24     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@joaquinrivero joaquinrivero changed the title MWPW-170589: POC Loading Unity block and dependancies after LCP MWPW-170589: POC Loading Unity after LCP Mar 29, 2025
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (2)

acrobat/blocks/verb-widget/verb-widget.js:463

  • Consider awaiting loadUnityAfterLCP() to handle potential errors unless fire-and-forget execution is intentional.
loadUnityAfterLCP();

acrobat/blocks/verb-widget/verb-widget.js:468

  • Consider awaiting loadUnityAfterLCP() to ensure any errors during Unity block loading are caught, unless non-blocking behavior is desired.
loadUnityAfterLCP();

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit

eslint

🚫 [eslint] <object-curly-spacing> reported by reviewdog 🐶
A space is required after '{'.

if(canSendDataToSplunk) window.analytics.sendAnalyticsToSplunk(event, VERB, {...metadata, errorData}, getSplunkEndpoint());


🚫 [eslint] <object-curly-spacing> reported by reviewdog 🐶
A space is required before '}'.

if(canSendDataToSplunk) window.analytics.sendAnalyticsToSplunk(event, VERB, {...metadata, errorData}, getSplunkEndpoint());


🚫 [eslint] <no-use-before-define> reported by reviewdog 🐶
'getSplunkEndpoint' was used before it was defined.

if(canSendDataToSplunk) window.analytics.sendAnalyticsToSplunk(event, VERB, {...metadata, errorData}, getSplunkEndpoint());


🚫 [eslint] <indent> reported by reviewdog 🐶
Expected indentation of 6 spaces but found 4.

? 'https://unity.adobe.io/api/v1/log'


🚫 [eslint] <indent> reported by reviewdog 🐶
Expected indentation of 6 spaces but found 4.

: 'https://unity-stage.adobe.io/api/v1/log';


🚫 [eslint] <no-trailing-spaces> reported by reviewdog 🐶
Trailing spaces not allowed.

: 'https://unity-stage.adobe.io/api/v1/log';


🚫 [eslint] <max-len> reported by reviewdog 🐶
This line has a length of 108. Maximum allowed is 100.

function handleAnalyticsEvent(eventName, metadata, documentUnloading = true, canSendDataToSplunk = true) {


🚫 [eslint] <keyword-spacing> reported by reviewdog 🐶
Expected space(s) after "if".

if(!canSendDataToSplunk) return;


🚫 [eslint] <no-multi-spaces> reported by reviewdog 🐶
Multiple spaces found before 'return'.

if(!canSendDataToSplunk) return;


🚫 [eslint] <no-shadow> reported by reviewdog 🐶
'userAttempts' is already declared in the upper scope on line 491 column 9.

function handleUploadingEvent(data, userAttempts, cookieExp, canSendDataToSplunk) {


🚫 [eslint] <no-shadow> reported by reviewdog 🐶
'userAttempts' is already declared in the upper scope on line 491 column 9.

function handleUploadedEvent(data, userAttempts, cookieExp, canSendDataToSplunk) {

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit

eslint

🚫 [eslint] <no-shadow> reported by reviewdog 🐶
'userAttempts' is already declared in the upper scope on line 491 column 9.

function handleUploadedEvent(data, userAttempts, cookieExp, canSendDataToSplunk) {

* stage:
  send browser tab closure event to splunk

# Conflicts:
#	acrobat/blocks/verb-widget/verb-widget.js
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

Successfully merging this pull request may close these issues.

2 participants