bootlint
bootlint copied to clipboard
W005 wrongly assumes $ is jQuery
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 forjQuery
, 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;