Overview
Yoopta Editor is designed for performance, but large documents and complex plugins can impact rendering speed and user experience. This guide covers strategies to optimize your editor implementation.Key Performance Factors
1. Document Size
- Small docs (< 50 blocks): No optimization needed
- Medium docs (50-200 blocks): Basic optimizations recommended
- Large docs (200-1000 blocks): Advanced optimizations required
- Very large docs (1000+ blocks): Consider pagination or lazy loading
2. Plugin Complexity
- Simple plugins (Paragraph, Headings): Minimal impact
- Media plugins (Image, Video, Embed): Moderate impact
- Complex plugins (Table, Code with syntax highlighting): Higher impact
Optimization Strategies
Memoization
Memoize Editor Instance
Always memoize the editor instance to prevent recreation:Memoize Plugins Array
Memoize your plugins array if it’s defined in the component:Batch Operations
UsebatchOperations to group multiple changes:
Debounce Save Operations
Debounce expensive operations like saving to backend:Loading Strategies
Initial Load Optimization
Load Content Asynchronously
Progressive Rendering
Render editor shell first, load plugins progressively:Pagination for Large Documents
Implement virtual scrolling or pagination:Media Optimization
Lazy Load Images
Use native lazy loading for images:Image Optimization
Optimize images before upload:Video Optimization
Use poster images and lazy loading for videos:Code Plugin Optimization
Lazy Load Syntax Highlighter
Limit Syntax Highlighting
Disable highlighting for very long code blocks:History Optimization
Limit History Stack Size
Control undo/redo history size:Disable History for Bulk Operations
Monitoring Performance
Measure Render Time
Track Document Size
Best Practices
Profile before optimizing
Profile before optimizing
Use React DevTools Profiler to identify actual bottlenecks before optimizing. Don’t optimize prematurely.
Minimize dependencies
Minimize dependencies
Only include plugins you actually use. Each plugin adds overhead:
Use production builds
Use production builds
Always use production builds in production:Development builds include extra checks and warnings that slow down performance.
Optimize bundle size
Optimize bundle size
Use tree-shaking and code splitting:
Monitor in production
Monitor in production
Use tools like Sentry or LogRocket to monitor real-world performance:
- Track slow renders
- Monitor bundle size
- Measure time to interactive (TTI)
Performance Checklist
- Editor instance is memoized
- Plugins array is defined outside component or memoized
- onChange handler is debounced for expensive operations
- Large documents use pagination or virtual scrolling
- Images are optimized and lazy-loaded
- Videos use poster images and metadata preload
- Code highlighting is disabled for very long blocks
- Batch operations are used for bulk updates
- History stack size is limited
- Production build is used in production
- Performance monitoring is in place
Related
Troubleshooting
Common issues and solutions
Best Practices
General best practices