title: Vue components on demand - [Vue warn]: Cannot find element
body: <p>I am working on a php/laravel project that requires using some vue components in some areas. Currently, my vue component looks as follows:</p>
  
  <pre><code>import Vue from 'vue';
  
  import Notification from "./components/Notification.vue";
  
  window.onload = function () {
     var main = new Vue({
        el: '#my-app',
        components: { Notification }
     });
  }
  </code></pre>
  
  <p>However, on pages where I do not have a #my-app element I am getting the following error:</p>
  
  <pre><code>[Vue warn]: Cannot find element: #my-app 
  </code></pre>
  
  <p>Is there a way to prevent this warning? Another way to ask this is, is there way to use my notification component on pages where I need it by creating a #my-app element and not have a #my-app element altogether on pages were I do not need it?</p>
  
  <p>Or if I understand this correctly, I need a root #my-app element regardless of if I'm using the Notification component?  </p>