Vue 2 Cdn

Posted on  by admin

You can load Vue from a CDN using a script tag.For example, here's how you can load the latest version of Vue 2.x:.

More Vue Tutorials

Once you load Vue via CDN, Vue will be a global variable that you can use normally.For example, the below is a standalone HTML page that loads Vue 2.x and adds interactivity.

When to Use CDN versus Bundling

Below is a live example. If you include Vue in your JavaScript files using const Vue = require('vue') or import Vue from 'vue', you can still load Vue from a CDN if you define Vue as a Webpack external.

Release Notes

There are several advantages to loading Vue via a CDN as opposed to bundling it yourself.For one, the browser can cache Vue separately from your application, which can lead to betterperformance if you update your app frequently but use the same version of Vue.

For another,your build step will be faster. However, the Vue docs recommend using bundling rather than loading from a CDN for "building large scale applications with Vue".

Vue Devtools

Here's a few reasonswhy you might choose to bundle Vue with Webpack rather than loading via CDN. The mostimportant reason is single file components: youneed to include Vue in your build step to get SFC support.