0
0
Vueframework~8 mins

Nuxt project structure in Vue - Performance & Optimization

Choose your learning style9 modes available
Performance: Nuxt project structure
MEDIUM IMPACT
This affects the initial page load speed and rendering performance by organizing how components, pages, and assets are loaded and rendered.
Organizing pages and components for optimal loading
Vue
pages/
  index.vue
  about.vue
components/
  Header.vue
  Footer.vue
  BigComponent.vue

// Use automatic component import or lazy load BigComponent only where needed
Only loads components when needed, reducing initial bundle size and speeding up page load.
📈 Performance GainSaves 100-200kb on initial load, improves LCP by 200-400ms
Organizing pages and components for optimal loading
Vue
pages/
  index.vue
  about.vue
components/
  Header.vue
  Footer.vue
  BigComponent.vue

// All components imported globally in nuxt.config.js
Importing all components globally causes the entire component code to load on every page, increasing bundle size and slowing initial load.
📉 Performance CostAdds 100-200kb to initial bundle, blocking rendering longer
Performance Comparison
PatternDOM OperationsReflowsPaint CostVerdict
Global import of all componentsLowLowHigh due to large JS bundle[X] Bad
Lazy loading components per pageLowLowLow due to smaller JS bundles[OK] Good
Static assets in assets folder referenced relativelyN/AN/ABlocks paint until loaded[!] OK
Static assets in public folder with cachingN/AN/ANon-blocking paint with caching[OK] Good
Rendering Pipeline
Nuxt project structure influences how the browser processes HTML, CSS, and JavaScript by controlling code splitting, lazy loading, and asset delivery.
HTML Parsing
JavaScript Execution
Style Calculation
Layout
Paint
⚠️ BottleneckJavaScript Execution due to large bundles from poor structure
Core Web Vital Affected
LCP
This affects the initial page load speed and rendering performance by organizing how components, pages, and assets are loaded and rendered.
Optimization Tips
1Avoid global imports of all components to keep bundles small.
2Place static assets in the public folder for caching and faster delivery.
3Use automatic component imports or lazy loading to improve page load speed.
Performance Quiz - 3 Questions
Test your performance knowledge
How does importing all components globally in Nuxt affect performance?
AImproves caching and speeds up load
BIncreases initial bundle size and slows page load
CHas no effect on performance
DReduces JavaScript execution time
DevTools: Performance
How to check: Record page load, look at Main thread for long JS execution and large bundle parsing times
What to look for: Long scripting times and large JS files indicate poor project structure causing slow LCP