Skip to content

⚡ Bolt: optimize scroll performance and re-renders#2

Open
VagueDustin wants to merge 1 commit into
mainfrom
jules-525147790602385307-6b90b61a
Open

⚡ Bolt: optimize scroll performance and re-renders#2
VagueDustin wants to merge 1 commit into
mainfrom
jules-525147790602385307-6b90b61a

Conversation

@VagueDustin

Copy link
Copy Markdown
Owner

Implemented scroll event throttling, cached heading elements, and optimized state management to reduce unnecessary re-renders. High-frequency scroll events were previously causing excessive DOM queries and component re-renders, impacting performance on large documents. This change significantly reduces main thread work during scrolling and ensures the application remains responsive.


PR created automatically by Jules for task 525147790602385307 started by @VagueDustin

This commit implements several performance optimizations in the document viewer:
- Throttled scroll events using requestAnimationFrame to ensure updates happen at the display's refresh rate.
- Cached heading elements in a Ref to avoid expensive querySelectorAll calls on every scroll tick.
- Used a Ref for active heading tracking to prevent the scroll listener from being torn down and re-added on every heading change.
- Added passive scroll listeners for improved scrolling performance.
- Memoized core functions (processMarkdown, scrollToHeading) using useCallback to maintain reference stability.
- Moved the matchesShortcut utility outside the component to avoid re-creation.
- Cleaned up unused state and fixed linting issues.

Co-authored-by: VagueDustin <127912586+VagueDustin@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown

👋 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.

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