Skip to content

Commit 410739b

Browse files
author
Karen Baney
committed
updated readme and pptx
1 parent 34bc8ce commit 410739b

File tree

2 files changed

+36
-3
lines changed

2 files changed

+36
-3
lines changed

Lazy Way To Performance.pptx

511 Bytes
Binary file not shown.

README.md

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,39 @@
11
# lazydemo
2+
This is a simple demo showing how to:
3+
1. Lazy Load Components in Vue 2
4+
2. Lazy Load Routes in Vue 2
5+
Bonus: vue.config.js shows how to split out vendor's chunk
6+
7+
## Lazy Load Components
8+
In the /views/home.vue component, Bella is shown by default so we can lazy load the Daisy component since it's not visible on the initial page load.
9+
10+
What to Lazy Load? Anything that isn't visible on initial page load. (using v-if)
11+
- Tabs (other than the default)
12+
- Side Panel
13+
- Modals
14+
15+
16+
## Lazy Load Routes
17+
In the /router/index.js, the About page is already lazy loaded.
18+
19+
Typcially, there's not much value in lazy loading the home page, since it is the entry point of the application. If you have multiple entry points, then you may want to lazy load those.
20+
21+
To Lazy Load the Bella and Daisy routes, just change the import to a dynamic import. Change this:
22+
```
23+
import Bella from '@/components/bella'
24+
```
25+
to this:
26+
```
27+
const Bella = () => import('@/components/bella')
28+
```
29+
30+
### Specifying Webpack Chunk Name
31+
1. Babel.config.js must have comments to true for this to work.
32+
2. Add the webpack magic comment to the dynamic import
33+
34+
```
35+
const Bella = () => import(/*webpackChunkName: "dogs" */ '@/components/bella')
36+
```
237

338
## Project setup
439
```
@@ -7,7 +42,7 @@ npm install
742

843
### Compiles and hot-reloads for development
944
```
10-
npm run serve
45+
npm run dev
1146
```
1247

1348
### Compiles and minifies for production
@@ -20,5 +55,3 @@ npm run build
2055
npm run lint
2156
```
2257

23-
### Customize configuration
24-
See [Configuration Reference](https://cli.vuejs.org/config/).

0 commit comments

Comments
 (0)