I often see in my code I am loading from my company's media central that jQuery is not available in the console normally. (No $
and jQuery
)
But sometimes, to those elements to which jQuery is attached, it has a long number with it.
jQuery18306575689211022109_1378907534666
What is the purpose of doing this? Security?
Also, jQuery is sometimes available directly in the console, but only with the above numbers. I am therefore unable to debug my apps in console, where I need to query using jQuery.
However, in the JavaScript code, jQuery is perfectly being used as $
and jQuery
. So I apply a break-point and export as window.jQuery = jQuery
.
Is this a proper way to debug the app, when jQuery
is obfuscated?
UPDATE:
For eg., check this URL the app is calling. It seems that the URL knows what is the number appended to jQuery. How do I come to know of the same number while debugging? Any lights on what is going on?
It's a callback id automatically generated by jQuery. See the documentation for
jsonpCallback
.It seems that you are confusing two different variables. You can make a quick test on this website : http://www.jquery4u.com/function-demos/jsonp/#demo. Click "run demo", open Chrome's console, type "jQuery" in order to retrieve the callback's name, then perform this simple comparison :
That said, the fact that the variables named "$" and "jQuery" are not available in your case may be due to a specific implementation. One possibility could be the use of
jQuery.noConflict()
which allows either to customize the name used as a reference to jQuery, or to completely remove all references to jQuery from the global scope (window
), so there is no way to access it in the console.