vue.js logo

Dynamic Component Loading


To optimize your application and improve load times, you can use Vue's asynchronous components along with Webpack's code splitting feature. This approach is particularly useful for larger applications where you want to load components only when they are actually required.


<template>
        <div>
          <component :is="asyncComponent" />
        </div>
      </template>

      <script>
      export default {
        data() {
          return {
            asyncComponent: null
          };
        },
        mounted() {
          this.asyncComponent = () => import('./components/LargeComponent.vue');
        }
      }
      </script>