Skip to content

Unused Lazy Loading Import Not Implemented Properly #108

Description

@Harsh-vardhan09

Severity: MEDIUM
Component: Frontend - Athlead-client/src/App.jsx

Description

Events component is lazy loaded but EventCardSkeleton is imported directly (not lazy), which defeats the purpose of code splitting.

Current Code (Lines 950-951)

const LazyEvents = React.lazy(() => import("./pages/Events"));
import EventCardSkeleton from "./Components/EventCardSkelton";  // Not lazy - imported directly

Impact

  • EventCardSkeleton still included in main bundle
  • Code splitting benefits are reduced
  • App bundle size not optimized
  • Inconsistent lazy loading strategy

Solution

const LazyEvents = React.lazy(() => import("./pages/Events"));
const LazyEventCardSkeleton = React.lazy(() => import("./Components/EventCardSkelton"));
 
// Use in fallback
<React.Suspense
  fallback={
    <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-10 my-8 w-full lg:px-20">
      {Array.from({ length: 6 }).map((_, i) => (
        <LazyEventCardSkeleton key={i} />
      ))}
    </div>
  }
>
  <LazyEvents />
</React.Suspense>

Tasks

  • Analyze which components should be lazy loaded
  • Implement lazy loading for heavy components
  • Check bundle size before/after with npm run build
  • Test Suspense fallback UI
  • Monitor bundle size in CI/CD

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrontendThis is an issue related to frontendIntermediateThis is an intermediate level of issueOpen-to-AllThis is an issue that can be assigned to anyone and work on it.duplicateThis issue or pull request already existsgood first issueGood for newcomers

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions