Consider a Vue app using lazy loading for routes. What is the main effect on the app's behavior?
Think about how lazy loading helps with app performance by delaying loading.
Lazy loading means the component code is fetched only when needed, so the app starts faster.
Given Vue Router, which option correctly lazy loads the About component?
const routes = [ { path: '/about', component: /* ??? */ } ];
Lazy loading uses a function that returns a dynamic import promise.
The correct syntax uses an arrow function returning import() to lazy load the component.
Look at this route definition:
const routes = [{ path: '/home', component: import('./Home.vue') }];What error will occur and why?
Check what the component property expects for lazy loading.
The component property must be a function returning a Promise, not the Promise itself. Using import() directly returns a Promise, causing a TypeError.
In a Vue app, if you lazy load the Profile route component, what happens to the app's initial JavaScript bundle size?
Think about how code splitting affects the main bundle.
Lazy loading splits the component into a separate file, so the main bundle is smaller and loads faster.
Lazy loading delays loading a route's component until navigation. Prefetching loads it earlier. Why combine both?
Consider balancing fast startup and smooth navigation.
Prefetching loads lazy components in the background before the user navigates, so navigation feels instant without slowing initial load.