What is jQuery18007779947370290756

jquery

Solution

jQuery adds this property to elements when you store data on them. As this property is on the `window` element, somewhere in your code you're doing something equivalent to:

$(window).data('something', 1);

Note that jQuery events also uses the `data` module behind the scenes, so this could also be because you're adding an event to the `window` object.

For normal nodes (i.e. elements with a `nodeType` property), this value is set to a GUID (data.js#61), and the data you want to store on that object is stored in a global jQuery cache.

However the `window` element does not have a `nodeType` property, so it goes down the route of I'm a plain JS object; which leads the data to be stored directly on the object itself (which, in the case of `window`, may be a bug with jQuery).

The choice of cache location (global or on the object) is made in L39-45 in data.js:

// We have to handle DOM nodes and JS objects differently because IE6-7
// can't GC object references properly across the DOM-JS boundary
isNode = elem.nodeType,

// Only DOM nodes need the global jQuery cache; JS object data is
// attached directly to the object so GC can occur automatically
cache = isNode ? jQuery.cache : elem,

In the case of normal DOM elements, the value is assigned a GUID in data.js#61:

elem[ internalKey ] = id = jQuery.deletedIds.pop() || jQuery.guid++;

But in the case of normal JS objects (and `window` in this case), the object is built in 68 - 74:

cache[id] = {};

// Avoids exposing jQuery metadata on plain JS objects when the object
// is serialized using JSON.stringify
if (!isNode) {
    cache[id].toJSON = jQuery.noop;
}​

The weird value is `jQuery.expando`, which is defined in data.js#14, and is initialized to:

"jQuery" + ( jQuery.fn.jquery + Math.random() ).replace( /\D/g, "" )

(basically, "jQuery", followed by the jQuery version with "."'s removed (1800 in your case), and then a random number).

Problem

I use jQuery in my page, when I use Chrome developer tool, I found jQuery18007779947370290756 and jQuery object in Console. jQuery18007779947370290756 only contains a few methods. jQuery contains a lot more methods. so what is jQuery18007779947370290756 ? I do not have the url of the page, since it is internal page. the lib I include is just jquery-1.8.0.min.js and jquery-ui-1.8.23 and no JSONP calls. It looks like if I added a global event `'beforeunload'` to window object. and it is stored in window[expando]. However if I added some events to other DOM object such as `button`, and they are stored in jQuery.cache. here is the screen shot form jQuery.cache and window[jQuery1800xxxxxxxxxxxxxxxx] I am not sure why the guid for that 2 click events are both 8. those 2 click events are binded to 2 buttons. and click event handler are the same function.

Original source