Skip to content

perf(startup): lazy-load ABCJS library to reduce startup blocking#6080

Open
parthdagia05 wants to merge 3 commits intosugarlabs:masterfrom
parthdagia05:perf/lazy-widget-loding-phase3
Open

perf(startup): lazy-load ABCJS library to reduce startup blocking#6080
parthdagia05 wants to merge 3 commits intosugarlabs:masterfrom
parthdagia05:perf/lazy-widget-loding-phase3

Conversation

@parthdagia05
Copy link
Contributor

@parthdagia05 parthdagia05 commented Mar 4, 2026

Summary

Closes #5998

This PR implements Phase 4C of the startup performance optimization plan.

The ABCJS library (lib/abc.min.js, ~552KB) was previously loaded during application startup via a <script defer> tag in index.html.

However, ABCJS is only required when users perform ABC-related operations such as:

  • Importing ABC notation
  • Rendering ABC notation
  • Certain AI widget operations

Loading the library during startup caused unnecessary JavaScript parsing and increased Total Blocking Time.

Changes

• Removed the <script defer src="lib/abc.min.js"> tag from index.html
• Implemented a dynamic loader to load the library only when needed
• Ensured ABCJS is loaded before any code paths that use the ABCJS global

Before

ABCJS was loaded and parsed during startup regardless of user interaction.

After

ABCJS loads dynamically only when ABC functionality is triggered.

Impact

• ~552KB JavaScript removed from startup parsing
• Reduced Total Blocking Time
• Improved First Contentful Paint and Speed Index

Risk

Low risk.

ABCJS is only used in user-triggered flows and does not affect core runtime logic.

All functionality related to ABC import and notation rendering continues to work as expected.


PR Category

  • Bug Fix
  • Feature
  • Performance
  • Tests
  • Documentation
  • Performance

@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2026

✅ All Jest tests passed! This PR is ready to merge.

2 similar comments
@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2026

✅ All Jest tests passed! This PR is ready to merge.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2026

✅ All Jest tests passed! This PR is ready to merge.

@parthdagia05
Copy link
Contributor Author

@walterbender can you review PR

@walterbender
Copy link
Member

Why do we need multiple copies of EnsureABCJS

@parthdagia05
Copy link
Contributor Author

parthdagia05 commented Mar 9, 2026

@walterbender
Thanks for pointing that out. I introduced ensureABCJS in multiple files to guarantee the library was loaded before use, but that results in duplicated logic. I'll refactor this into a shared utility so all modules use a single loader.

@parthdagia05 parthdagia05 force-pushed the perf/lazy-widget-loding-phase3 branch from da9f235 to 967cda2 Compare March 9, 2026 08:26
@parthdagia05
Copy link
Contributor Author

this PR still needs changes.

@parthdagia05 parthdagia05 force-pushed the perf/lazy-widget-loding-phase3 branch from 967cda2 to 1e80cb4 Compare March 9, 2026 17:23
@github-actions
Copy link
Contributor

github-actions bot commented Mar 9, 2026

❌ Some Jest tests failed. Please check the logs and fix the issues before merging.

Failed Tests:

activity_listeners.test.js
GraphicsBlocks.test.js

@parthdagia05 parthdagia05 force-pushed the perf/lazy-widget-loding-phase3 branch from 1e80cb4 to c019e41 Compare March 9, 2026 17:30
@github-actions
Copy link
Contributor

github-actions bot commented Mar 9, 2026

❌ Some Jest tests failed. Please check the logs and fix the issues before merging.

Failed Tests:

GraphicsBlocks.test.js

@github-actions github-actions bot added the performance Improves performance (load time, memory, rendering) label Mar 9, 2026
@parthdagia05 parthdagia05 force-pushed the perf/lazy-widget-loding-phase3 branch from c019e41 to c366198 Compare March 9, 2026 17:36
@github-actions
Copy link
Contributor

github-actions bot commented Mar 9, 2026

❌ Some Jest tests failed. Please check the logs and fix the issues before merging.

Failed Tests:

GraphicsBlocks.test.js

@parthdagia05
Copy link
Contributor Author

@walterbender this PR is now ready to review, happy for further changes if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance Improves performance (load time, memory, rendering)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Performance] Lazy-load export and notation modules to reduce startup blocking time

2 participants