Skip to content

⚡ Bolt: Use event delegation for navigation links#43

Merged
ImChong merged 2 commits into
mainfrom
bolt-event-delegation-11563177718282961227
May 23, 2026
Merged

⚡ Bolt: Use event delegation for navigation links#43
ImChong merged 2 commits into
mainfrom
bolt-event-delegation-11563177718282961227

Conversation

@ImChong
Copy link
Copy Markdown
Owner

@ImChong ImChong commented May 23, 2026

💡 What: Replaced individual click event listeners on navLinks and tocLinks with a single delegated event listener attached to the document and tocNav parent, respectively. Uses e.target.closest() to catch the clicks.

🎯 Why: Attaching hundreds of event listeners in a loop is inefficient and consumes unnecessary memory. Event delegation improves initialization speed by binding only one listener per group of links.

📊 Impact: Reduces memory footprint and speeds up execution during initial page load, especially on pages with large table of contents.

🔬 Measurement: Verified the code behaves the same functionally. npm run check continues to pass cleanly.


PR created automatically by Jules for task 11563177718282961227 started by @ImChong

Replaces `querySelectorAll().forEach` iteration to attach `click` event listeners on multiple links with a single event listener attached to the parent container/document.
This reduces memory overhead and improves page load / initialization times.

Co-authored-by: ImChong <74563097+ImChong@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Run `npm run format` to automatically fix Prettier code style issues in `.jules/bolt.md` which failed the CI check.

Co-authored-by: ImChong <74563097+ImChong@users.noreply.github.com>
@ImChong ImChong merged commit 21b41f0 into main May 23, 2026
1 check passed
@ImChong ImChong deleted the bolt-event-delegation-11563177718282961227 branch May 23, 2026 15:56
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.

1 participant