Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unnecessary use of jQuery global #24167

Closed
thheller opened this issue Sep 29, 2017 · 2 comments
Closed

Unnecessary use of jQuery global #24167

thheller opened this issue Sep 29, 2017 · 2 comments
Labels

Comments

@thheller
Copy link

It seems to me that bootstrap still has an artificial dependency on the jQuery global that seems unnecessary.

At the top of the file jquery is imported but then the jQuery global is used.

import $ from 'jquery'

But then the "check" uses the global

(() => {
if (typeof jQuery === 'undefined') {
throw new Error('Bootstrap\'s JavaScript requires jQuery. jQuery must be included before Bootstrap\'s JavaScript.')
}
const version = $.fn.jquery.split(' ')[0].split('.')
const min = 3
const max = 4
if (version[0] < min || version[0] >= max) {
throw new Error('Bootstrap\'s JavaScript requires at least jQuery v3.0.0 but less than v4.0.0')
}
})(jQuery)

This pattern is repeated in other files as well, the top imports jquery as $ but then uses jQuery in code. Should it not use $ instead?

I'm asking from a build tool perspective which wouldn't have any issues if the imported object was used instead of the global?

@XhmikosR
Copy link
Member

@Johann-S: should we also check for $ in index.js? This should be more flexible.

@Johann-S
Copy link
Member

Johann-S commented Oct 3, 2017

yep agreed with @thheller

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants