0
0
Vueframework~5 mins

Lazy loading routes in Vue - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is lazy loading in the context of Vue routes?
Lazy loading means loading route components only when the user visits that route, not before. This helps make the app faster by not loading everything at once.
Click to reveal answer
beginner
How do you define a lazy loaded route component in Vue Router?
Use a function that returns an import statement, like: <br><code>{ path: '/about', component: () => import('./About.vue') }</code>. This tells Vue to load the component only when needed.
Click to reveal answer
beginner
Why is lazy loading routes beneficial for user experience?
It reduces the initial load time of the app, so users see the page faster. It also saves bandwidth by loading only what is needed.
Click to reveal answer
intermediate
What happens if you don’t use lazy loading for routes in a large Vue app?
All route components load at once, making the app slower to start and use more data upfront, which can frustrate users.
Click to reveal answer
intermediate
Can lazy loading routes affect SEO or accessibility?
Lazy loading routes usually does not affect SEO if server-side rendering is used. For accessibility, ensure loading states are clear and navigation is keyboard-friendly.
Click to reveal answer
How do you write a lazy loaded route in Vue Router?
A{ path: '/home', component: () => import('./Home.vue') }
B{ path: '/home', component: './Home.vue' }
C{ path: '/home', component: import('./Home.vue') }
D{ path: '/home', component: function() { return './Home.vue' } }
What is the main benefit of lazy loading routes?
AFaster initial app load
BMore complex code
CLoads all components upfront
DSlower navigation between pages
Which Vue Router version introduced official support for lazy loading routes?
AVue Router 2
BVue Router 1
CVue Router 4
DVue Router 3
What does the import() function return when used in lazy loading?
AA string path
BA promise that resolves to the component
CThe component immediately
DAn error
Which of these is NOT a benefit of lazy loading routes?
AReduced initial bundle size
BImproved app startup speed
CAutomatic SEO optimization
DLower bandwidth usage on first load
Explain how lazy loading routes work in Vue and why they improve app performance.
Think about when components are loaded and how that affects speed.
You got /4 concepts.
    Describe how you would implement lazy loading for a new route in a Vue app.
    Focus on the route object and the component property.
    You got /4 concepts.