Home > Net >  How can we directly include vue-custom-element in HTML file as a Script?
How can we directly include vue-custom-element in HTML file as a Script?

Time:10-01

How can we directly include vue-custom-element in HTML file as a Script?

On the documentation they have mentioned we can directly include vue-custom-element globaly but I cannot find vue-custom-element.js file anywhere.

So How can we implement it directly in HTML file like this

<script src="https://cdn.jsdelivr.net/npm/vue"></script>
<script src="https://path/to/vue-custom-element.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/document-register-element/1.4.1/document-register-element.js"></script>

CodePudding user response:

You're looking at the project's GitHub page, which contains vue-custom-element.js. The implication is that you host it yourself on your server.

Other third-party CDN sites like jsdelivr will host the file as https://cdn.jsdelivr.net/npm/[email protected]/dist/vue-custom-element.min.js (etc), and you could use those at your own risk. There may be other providers, but StackOverflow is not a good place to manage an exhaustive list of third-party resources.

You're already using jsdelivr for the vue package, but as with all third party hosting there's no guarantee that the site and file will continue to exist and will not replace your dependency with a nefarious alternative. (The HTML SRI option provides a hash commitment that would help ensure you know what you're including, though.)

  • Related