How to do it...

Create a new project with vue-cli by making a new directory and running the following command:

vue init webpack

You can answer the question as you prefer, as long as you add the vue-router to the template when asked.

We will create two components: one will be our home page and it will be small and light, the other component will be very big and very slow to load. What we want to achieve is to load the home page immediately, without having to wait for the huge component to be downloaded by the browser.

Open the Hello.vue file in the components folder. Delete everything and only leave the following:

<template>  <div>    Lightweight hello  </div></template>

In the same folder, create another file named Massive.vue and write the ...

Get Vue.js 2 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.