0

I want to be able to use Vue components distributed over CDN without the need to npm install them - in my single-file Vue components.

I do not understand how to import them by URL to compiled component. Example of components I want to import is https://unpkg.com/vueperslides (from https://antoniandre.github.io/vueper-slides/#installation)

As I understand there is a way to load JS file in mounted() hook or something, but I don't understand how to import exports from it after.

Answers I tried include https://markus.oberlehner.net/blog/distributed-vue-applications-loading-components-via-http/ How to add external JS scripts to VueJS Components and many others.

I am building a web app using Quasar Framowrk on Vue.js v2

Tibebes. M
  • 6,940
  • 5
  • 15
  • 36
  • This is a very strange way of thinking. Usually you don't load js code to execute after building your appllication. What you want is code injection - someting that isn't a good practice. You will run into many problems if you try because it will circumvent security measures provided by all browsers. – Hexodus Sep 28 '20 at 18:54
  • @Hexodus so it is better to always use local copy of a library when building an app, and never reference libraries distributed via CDN, unless absolutely necessary? – Karakatiza666 Sep 29 '20 at 06:59
  • 1
    I seriously missanderstood your intention as code injection but it turns out it's all about using CDN. In this case the way would be using something like: https://www.npmjs.com/package/webpack-cdn-plugin – Hexodus Sep 29 '20 at 11:52

0 Answers0