I have a collection of Javascript files that together constitute a system. Different parts of the system are in different (global) namespaces (eg, NSA, NSB, etc.) and those namespaces may be objects, eg
NSA = {
... lots of stuff ...
}
Now, in my various modules, I may have code such as:
NSA.method();
My code JSLints clean because I declare these namespaced objects in a comment at the top of the file:
/*global dNSA NSB NSC */
When I run YUI Compressor (v 2.4.2) on these files with the -v (verbose) switch, it emits warnings about the referenced namespaced objects, such as:
Found an undeclared symbol: $
and that's for using $ for jQuery!
What can I do to define these variables so that YUI Compressor doesn't emit the warning, yet whatever I add can't cause a change to the object.
The YUI library doesn't recognize Jquery, so it "thinks" its an error. Seems like it's nothing to worry about.
Add
var $ = window.$;
to your code.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.