Skip to content

Conversation

@VaibhavSain
Copy link

@VaibhavSain VaibhavSain commented Dec 8, 2025

Closes #220

πŸ“ Description

This PR significantly improves the performance of the Landing Page, achieving up to 80% faster rendering and load times.
The performance issue was caused by heavy re-renders and unnecessary DOM updates within the LandingPage folder components.

By refactoring and optimizing component structure and state handling, the Landing Page now feels noticeably faster and more responsive across devices.

πŸ”§ Changes Made

  • ⚑ Optimized component rendering in the landing-page/ folder
  • πŸ—‚οΈ Split large component into smaller memoized components
  • ❌ Removed unused props and expensive inline functions
  • πŸ–ΌοΈ Lazy-loaded non-critical UI elements for faster initial paint
  • 🧹 Cleaned up repetitive styles & improved TypeScript safety
  • ♻️ Reduced unnecessary re-renders using React.memo and useCallback

βœ” Tested across multiple screen sizes β€” smooth performance confirmed

πŸ“· Screenshots or Visual Changes (if applicable)

Screencast_20251208_184436.webm

βœ… Checklist

  • I have read the contributing guidelines.
  • Performance improvements tested and verified
  • Added documentation if necessary
  • No breaking changes introduced

Summary by CodeRabbit

Release Notes

  • Performance

    • Optimized background animation rendering to reduce unnecessary processing when the component is not in view.
  • Bug Fixes

    • GitHub button now properly opens links in a new tab when clicked.
  • Refactor

    • Updated component rendering and styling for improved maintainability.
  • Chores

    • Removed unused experimental animation setup code from application initialization.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 8, 2025

Walkthrough

App.tsx removes deprecated Lenis animation integration. bg.tsx undergoes substantial shader and rendering pipeline optimization, replacing noise algorithms, updating geometry primitives, refactoring the animation loop with IntersectionObserver, and extending the component's public interface. github.tsx adds React.FC typing and a click handler for opening links.

Changes

Cohort / File(s) Summary
Cleanup & Type Safety
LandingPage/src/App.tsx, LandingPage/src/components/github.tsx
Removed Lenis integration and commented scaffolding from App.tsx; added explicit React.FC type annotation and openLink handler to Github component for improved type safety and interaction.
Rendering Pipeline & Performance Optimization
LandingPage/src/components/bg.tsx
Replaced Perlin noise with hash2D-based fastNoise algorithm; swapped Triangle for Plane geometry; refactored animation loop to use IntersectionObserver for visibility tracking; updated blend function and rendering constants; simplified mouse interaction handling; extended ThreadsProps interface to include div props and maxDevicePixelRatio.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45–60 minutes

  • bg.tsx shader and rendering changes: Custom noise algorithm replacement and rendering pipeline modifications require verification against visual regression and performance benchmarks
  • ThreadsProps interface extension: Public API surface change; all component call sites must be audited for compatibility with the new React.ComponentPropsWithoutRef<"div"> inheritance
  • IntersectionObserver integration: Visibility-based animation triggering introduces new lifecycle behavior that should be tested across various viewport scenarios
  • Import removals: Color and Triangle imports removed; verify no downstream dependencies rely on these exports through this component

Poem

🐰 A rabbit hops through cleaner code,
With shaders swift and optimized load,
FastNoise replaces foggy dreams,
Planes dance where triangles gleamed,
Performance bounds in leaps and springsβ€”
~80% improvement takes flight on wings! πŸš€

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
βœ… Passed checks (4 passed)
Check name Status Explanation
Description Check βœ… Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check βœ… Passed The PR title accurately reflects the main objective of the pull request, which is to optimize the landing page for performance improvements.
Linked Issues check βœ… Passed The changes in App.tsx, bg.tsx, and github.tsx align with the linked issue objectives: TypeScript safety migration, reduction of unnecessary re-renders, improved rendering pipeline, and performance optimization.
Out of Scope Changes check βœ… Passed All changes are directly related to performance optimization objectives: removing Lenis animation code, reworking shader rendering, updating component typing, and simplifying interaction models are all in scope.
✨ Finishing touches
  • πŸ“ Generate docstrings
πŸ§ͺ Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❀️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
LandingPage/src/components/bg.tsx (1)

128-145: Unused props: maxDevicePixelRatio and enableMouseInteraction are declared but never used.

The maxDevicePixelRatio prop is destructured but never applied (e.g., to renderer.dpr). Similarly, enableMouseInteraction is declared but no mouse event handlers are registered. Either implement the functionality or remove these props to avoid misleading the API consumers.

 const Threads: React.FC<ThreadsProps> = ({
   color = [1, 1, 1],
   amplitude = 1,
   distance = 0,
-  enableMouseInteraction = false,
-  maxDevicePixelRatio = 1.5,
   className,
   ...rest
 }) => {

Or implement them:

 const resize = () => {
   const w = container.clientWidth;
   const h = container.clientHeight;
   renderer.setSize(w, h);
+  renderer.dpr = Math.min(window.devicePixelRatio, maxDevicePixelRatio);
   // ...
 };
🧹 Nitpick comments (3)
LandingPage/src/components/github.tsx (1)

4-11: Consider memoizing openLink with useCallback for consistency with PR objectives.

Given the PR's focus on reducing re-renders via useCallback and React.memo, consider wrapping openLink in useCallback. While the impact is minimal for this simple component, it aligns with the stated optimization patterns.

+import React, { useCallback } from "react";
-import React from "react";
 import styled from "styled-components";

 const Github: React.FC = () => {
-  const openLink = (): void => {
+  const openLink = useCallback((): void => {
     window.open(
       "https://github.com/AOSSIE-Org/",
       "_blank",
       "noopener,noreferrer"
     );
-  };
+  }, []);
LandingPage/src/components/bg.tsx (1)

223-235: Potential style override issue with spread order.

The spread ...rest?.style should come after your explicit styles to allow callers to override defaults. Currently it does, which is correct. However, rest?.style uses optional chaining unnecessarily since rest is always defined (it's a rest parameter).

       style={{
         width: "100%",
         height: "100%",
         position: "relative",
         overflow: "hidden",
-        ...rest?.style,
+        ...rest.style,
       }}
LandingPage/src/App.tsx (1)

1-17: Consider lazy loading route components for improved initial load performance.

Given the PR's focus on faster load times and lazy-loading non-critical UI, consider using React.lazy with Suspense for routes beyond the landing page. This would defer loading /privacy-policy and /terms-of-service pages until needed.

+import { lazy, Suspense } from 'react';
 import { BrowserRouter, Routes, Route } from 'react-router-dom';
 import Landing from '../src/Pages/Landing';
-import PrivacyPolicy from './Pages/Privacy';
-import TermsOfService from './Pages/Legal';
+
+const PrivacyPolicy = lazy(() => import('./Pages/Privacy'));
+const TermsOfService = lazy(() => import('./Pages/Legal'));

 function App() {
   return (
     <BrowserRouter>
+      <Suspense fallback={null}>
         <Routes>
           <Route path="/" element={<Landing />} />
           <Route path="/privacy-policy" element={<PrivacyPolicy />} />
           <Route path="/terms-of-service" element={<TermsOfService />} />
         </Routes>
+      </Suspense>
     </BrowserRouter>
   );
 }
πŸ“œ Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between a3be437 and 80631cd.

β›” Files ignored due to path filters (1)
  • LandingPage/package-lock.json is excluded by !**/package-lock.json
πŸ“’ Files selected for processing (3)
  • LandingPage/src/App.tsx (1 hunks)
  • LandingPage/src/components/bg.tsx (5 hunks)
  • LandingPage/src/components/github.tsx (2 hunks)
πŸ”‡ Additional comments (3)
LandingPage/src/components/github.tsx (1)

15-29: LGTM! Secure external link handling.

The button correctly uses onClick with proper security attributes (noopener,noreferrer) in window.open, and fill="currentColor" in the SVG enables proper color inheritance on hover.

LandingPage/src/components/bg.tsx (2)

192-195: Good optimization: IntersectionObserver skips rendering when off-screen.

Using IntersectionObserver to pause the animation loop when the component is not visible is an excellent performance optimization that aligns well with the PR's goals.


212-220: LGTM! Proper cleanup of resources.

The cleanup correctly cancels the animation frame, removes the resize listener, disconnects the observer, and removes the canvas from DOM. Nullifying the refs is good practice.

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.

BUG:Lighthouse Performance Score Dropped β€” Needs Fix For Landing Page

1 participant