perf: Reduce TBT/CLS + improve a11y via layout fixes, chunked render, passive listeners, alt text#5915
Open
7se7en72025 wants to merge 1 commit intosugarlabs:masterfrom
Conversation
Contributor
|
✅ All Jest tests passed! This PR is ready to merge. |
- core: batch DOM reads/writes in activity.js and turtles.js to eliminate layout thrashing (FastDOM pattern). - blocks: chunk block initialization via setTimeout to reduce Total Blocking Time (TBT). - events: apply `passive: true` to touch and wheel listeners to unblock the compositor thread. - aiwidget: implement DocumentFragment for batched DOM insertion, AudioContext singleton, and WeakMap index caching. - a11y: auto-generate descriptive `alt` tags for dynamic toolbar images.
Contributor
|
✅ All Jest tests passed! This PR is ready to merge. |
f2970be to
9fad62f
Compare
Contributor
Author
|
Hi! @walterbender |
Contributor
|
✅ All Jest tests passed! This PR is ready to merge. |
kartikktripathi
approved these changes
Feb 26, 2026
Contributor
kartikktripathi
left a comment
There was a problem hiding this comment.
@walterbender LGTM.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Targets Lighthouse: reduces Total Blocking Time (TBT) and Cumulative Layout Shift (CLS) while improving img-alt accessibility.
Changes
_makeButton,_initializePalettes, andinit()so layout measurements happen before mutations, eliminating forced synchronous layouts.blocks.loadNewBlocks()into chunks of 20 blocks viasetTimeout(0)and_processOneBlock()to yield between batches and shrink Long Tasks.{ passive: true }whereverpreventDefault()is not called, letting the browser avoid blocking scroll.<img>buttons using the button label (stripping shortcut hints) so they pass Lighthouse’simg-altrule.Testing
<img>elements passimg-alt.