Skip to content Skip to sidebar Skip to footer

Vuejs Lazy Loading Components Without The Router

Lazy loading components in vue is not difficult with webpack: https://alligator.io/vuejs/lazy-loading-vue-cli-3-webpack/ I am trying to strip the initial load of an app to the abso

Solution 1:

If someone needs an answer here it is. The lazy loading is already shipped with Vue without any plugins, that what I figured out recently.

Of course, this will work without Vue router.

const Component1 = () => import(
  /* webpackChunkName: "/js/component-name" */'./components/Component1'
)

const Component2 = () => import(
  /* webpackChunkName: "/js/component-name2" */'./components/Component2'
)

 const app = new Vue({
  el: '#app',
  components: {
    Component1,
    Component2
  }
})

Post a Comment for "Vuejs Lazy Loading Components Without The Router"