Vue: Allow loading Vue in "no conflict" mode

Created on 15 Feb 2016  ·  9Comments  ·  Source: vuejs/vue

Similar to jQuery:

var $j = jQuery.noConflict(true);
feature request

Most helpful comment

I think if you're using a bundling mechanism like Webpack or Browserify, this isn't even an issue. Vue doesn't add itself to window if it can just add itself to module.exports

All 9 comments

Just curious, what other library also uses a Vue global?

lol

@yyx990803 In my case - other version of Vue. I'm loading Vue on a number of websites, and although, none of them has ever used Vue yet - I'm optimistic - it might become much more popular in the future.

This feature would minimize any risk of overwriting older (or newer, or extended(!)) version of Vue, that is already being used on the website.

+1

I should elaborate. In my case, I use Vue because it's lightweight and it makes sense for a widget I'm building which will run on a lot of different sites. Those sites _probably_ don't use Vue, but I'd rather avoid potential version conflicts if I could.

I think if you're using a bundling mechanism like Webpack or Browserify, this isn't even an issue. Vue doesn't add itself to window if it can just add itself to module.exports

@sirlancelot that's exactly what I wanted to say :smile:

@sirlancelot I hadn't noticed that - I'm not in a place where I can use browserify et al, but simply defining module.exports before inclusion does the trick for me.

I think the best practice is: if you are expecting your code to run in an environment that you don't control, do not rely on window globals and do not expose window globals. Use a module bundler :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

robertleeplummerjr picture robertleeplummerjr  ·  3Comments

paceband picture paceband  ·  3Comments

paulpflug picture paulpflug  ·  3Comments

guan6 picture guan6  ·  3Comments

aviggngyv picture aviggngyv  ·  3Comments