Take the 2-minute tour ×

I have a collection of Javascript files that together constitute a system. Different parts of the system are in different (global) namespaces (e.g., NSA, NSB, etc.) and those namespaces may be objects, e.g.

 NSA = { 
    ... lots of stuff ...

Now, in my various modules, I may have code such as:


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.

share|improve this question
Ahh - seems this is a desired capability not yet provided. A ticket exists: yuilibrary.com/projects/builder/ticket/21 –  Zhami Aug 6 '10 at 23:19
I too am faced with the same issue. –  James Nov 1 '10 at 23:01
Make sure you use an up-to-date problem. I had this issues until I changed to version –  Patrick Jul 25 '13 at 11:05

2 Answers 2

The YUI library doesn't recognize Jquery, so it "thinks" its an error. Seems like it's nothing to worry about.

share|improve this answer
This is not a specific issue with jQuery, but with any global value that I use in different files that are all loaded into the same application. JSLint provides a mechanism for telling it that some global is defined outside the current file. I was hoping that YUIC would provide similar functionality. –  Zhami Nov 16 '10 at 16:52


var $ = window.$;

to your code.

share|improve this answer
I tried this, but alas it causes a critical failure under I.E., which does not preserve the value of $. I can't imagine why not. –  Zhami Nov 16 '10 at 16:50

Your Answer


