bootlint icon indicating copy to clipboard operation
bootlint copied to clipboard

W005 wrongly assumes $ is jQuery

Open deltab opened this issue 7 years ago • 0 comments

Bootlint looks at window.$ when checking for window.jQuery:

var globaljQuery = theWindow.$ || theWindow.jQuery;

but it should not do so as they can be different (e.g. Prototype and jQuery on the same page using $.noConflict). As jQuery's documentation states,

Many JavaScript libraries use $ as a function or variable name, just as jQuery does. In jQuery's case, $ is just an alias for jQuery, so all functionality is available without using $. If you need to use another JavaScript library alongside jQuery, return control of $ back to the other library with a call to $.noConflict().

I think there's no actual reason to look at $, as jQuery should always be defined when it's loaded.

var globaljQuery = theWindow.jQuery;

deltab avatar Jun 20 '17 17:06 deltab