Skip to content

Performance FAQ

Questions about optimizing VitePress site performance.

Build Performance

Q: My build is taking too long

A: Optimization strategies:

  1. Reduce the number of pages
  2. Optimize images before adding them
  3. Use dynamic imports for large components
  4. Enable parallel processing
  5. Use SSD storage for faster I/O

Q: How can I speed up the development server?

A: Tips for faster dev server:

  • Use --host flag for network access
  • Reduce the number of files being watched
  • Close unnecessary browser tabs
  • Use --debug to identify bottlenecks

Runtime Performance

Q: My site loads slowly for users

A: Performance improvements:

  1. Optimize images: Use WebP format, proper sizing
  2. Enable compression: Gzip/Brotli on server
  3. Use CDN: Serve static assets from CDN
  4. Minimize JavaScript: Remove unused code
  5. Lazy load content: Load content as needed

Q: How do I optimize images?

A: Image optimization techniques:

javascript
// In .vitepress/config.js
export default {
  vite: {
    plugins: [
      // Add image optimization plugin
    ]
  }
}
  • Use appropriate formats (WebP, AVIF)
  • Compress images before adding
  • Use responsive images with srcset
  • Implement lazy loading

Bundle Size

Q: My JavaScript bundle is too large

A: Reduce bundle size:

  1. Tree shaking: Remove unused code
  2. Code splitting: Split into smaller chunks
  3. Dynamic imports: Load components on demand
  4. Analyze bundle: Use bundle analyzer tools

Q: How do I analyze my bundle size?

A: Use bundle analysis tools:

bash
npm install --save-dev rollup-plugin-visualizer

Add to vite config:

javascript
import { visualizer } from 'rollup-plugin-visualizer'

export default {
  vite: {
    plugins: [
      visualizer({
        filename: 'dist/stats.html',
        open: true
      })
    ]
  }
}

Caching Strategies

Q: How do I implement proper caching?

A: Caching configuration:

  1. Static assets: Long-term caching with versioning
  2. HTML files: Short-term caching
  3. Service worker: For offline functionality
  4. CDN caching: Edge caching for global users

Q: My updates aren't showing for users

A: Cache busting solutions:

  • Check cache headers
  • Use versioned asset names
  • Implement proper cache invalidation
  • Clear CDN cache after deployment

Core Web Vitals

Q: How do I improve Largest Contentful Paint (LCP)?

A: LCP optimization:

  • Optimize server response times
  • Remove render-blocking resources
  • Optimize images and media
  • Use preload for critical resources

Q: How do I reduce Cumulative Layout Shift (CLS)?

A: CLS improvements:

  • Include size attributes on images
  • Reserve space for dynamic content
  • Use CSS aspect-ratio property
  • Avoid inserting content above existing content

Q: How do I improve First Input Delay (FID)?

A: FID optimization:

  • Minimize JavaScript execution time
  • Use web workers for heavy computations
  • Optimize third-party scripts
  • Implement code splitting

Monitoring

Q: How do I monitor my site's performance?

A: Monitoring tools:

  • Lighthouse: Built-in Chrome auditing
  • PageSpeed Insights: Google's performance tool
  • WebPageTest: Detailed performance analysis
  • Real User Monitoring: Track actual user experience

Q: What metrics should I track?

A: Key performance metrics:

  • Core Web Vitals: LCP, FID, CLS
  • Time to First Byte: Server response time
  • First Contentful Paint: Initial content rendering
  • Speed Index: Visual completeness
  • Total Blocking Time: Main thread blocking

VitePress Development Guide