Skip to content

[Performance] No lazy loading for heavy third-party dependencies in the initial bundle #741

Description

@RUKAYAT-CODER

Overview

package.json includes Monaco Editor (@monaco-editor/react), video.js, and ethers as top-level dependencies imported statically throughout the application. These libraries add 400KB+ to the initial JavaScript bundle, increasing Time to Interactive for all users, including those who never visit the editor, video, or Web3 pages.

Specifications

Features:

  • Monaco Editor, video.js, and ethers are loaded only when the pages that need them are visited
  • Initial bundle size is reduced by at least 200KB gzipped

Tasks:

  • Wrap Monaco Editor import with next/dynamic: const MonacoEditor = dynamic(() => import('@monaco-editor/react'), { ssr: false })
  • Apply the same pattern to video.js player component and ethers.js imports in client components
  • Run next build and compare bundle analysis before and after using ANALYZE=true

Impacted Files:

  • Any component importing @monaco-editor/react, video.js, or ethers directly
  • next.config.ts

Acceptance Criteria

  • Bundle analysis shows Monaco, video.js, and ethers in separate async chunks
  • Initial JS bundle is reduced by at least 200KB gzipped
  • Lazy-loaded components still function correctly after the dynamic import resolves

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions