Skip to content

⚡ Bolt: optimize Section component re-renders#81

Draft
google-labs-jules[bot] wants to merge 1 commit into
mainfrom
bolt-optimize-renders-12029781278911262176
Draft

⚡ Bolt: optimize Section component re-renders#81
google-labs-jules[bot] wants to merge 1 commit into
mainfrom
bolt-optimize-renders-12029781278911262176

Conversation

@google-labs-jules

Copy link
Copy Markdown
Contributor

This PR optimizes the Section and HeroSection components to improve rendering performance during scroll-based animations. By using direct DOM manipulation (via refs and classList/style) within IntersectionObserver callbacks instead of React state (useState), we eliminate unnecessary re-renders of the entire component tree whenever a section enters or leaves the viewport.

Key Changes:

  • src/components/section.tsx: Removed isVisible state and transitioned to direct classList.add('pop-up-child') manipulation.
  • src/components/sections/hero.tsx: Removed isHome state and transitioned to direct style property manipulation for transform and opacity.
  • .jules/bolt.md: Added a new journal entry documenting the learning that direct DOM manipulation is preferred for scroll-triggered animations in this architecture.

Impact:

  • Measurable Performance: Eliminates all React re-renders previously triggered by the IntersectionObserver during page navigation and scrolling.
  • Resource Efficiency: Reduces main thread work and improves scroll smoothness, especially on pages with multiple sections.

Verification:

  • Ran pnpm lint and pnpm build successfully.
  • Verified visual behavior via Playwright-generated screenshots (hero_initial.png, hero_exit.png, skills_visible.png).
  • Confirmed that animations still trigger correctly as the user scrolls.

PR created automatically by Jules for task 12029781278911262176 started by @amrabed

Optimize scroll-based animations by transitioning from React state to direct DOM manipulation within IntersectionObserver callbacks. This prevents redundant re-renders of section content and hero elements as they enter/leave the viewport.

💡 What:
- Replaced `isVisible` state with direct `classList` manipulation in `Section`.
- Replaced `isHome` state with direct `style` manipulation in `HeroSection`.
- Simplified viewport dimension lookups in both components.

🎯 Why:
Eliminates full component tree re-renders triggered by IntersectionObserver updates, improving scroll performance and reducing CPU usage.

📊 Impact:
Reduces re-renders during scrolling by 100% for the optimized components.

🔬 Measurement:
Verified functional parity via Playwright screenshots and confirmed build stability with `pnpm build`.
@google-labs-jules

Copy link
Copy Markdown
Contributor Author

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

@sonarqubecloud

Copy link
Copy Markdown

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.

0 participants