Performance: Plugin creation basics
MEDIUM IMPACT
Plugin creation affects initial app load time and runtime performance by adding extra code and possibly global reactive state.
import { createApp } from 'vue'; import App from './App.vue'; const app = createApp(App); // Lazy load plugin only when needed async function loadPlugin() { const { default: MyPlugin } = await import('./my-plugin'); app.use(MyPlugin); } loadPlugin(); app.mount('#app');
import { createApp } from 'vue'; import MyPlugin from './my-plugin'; const app = createApp(App); app.use(MyPlugin); app.mount('#app'); // MyPlugin registers many global components and heavy logic eagerly
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Eager plugin registration with many global components | High (many nodes registered) | Multiple reflows during mount | High paint cost due to many components | [X] Bad |
| Lazy-loaded plugin with selective global registration | Low (only needed nodes) | Single reflow on mount | Lower paint cost | [OK] Good |