Imagine that besides jQuery , we also have the XXX library, which also uses the window.$ Variable as the main identifier.
We load the XXX library - the variable window.$ Is defined.
We want to use it (the window.$ Variable) to access the XXX library; but at the same time, after loading the XXX library, we load jQuery , which will override window.$ for itself; BUT, first (before redefining) jQuery will back up the value of the variable window.$ Into its local variable _$ :
var // Map over jQuery in case of overwrite _jQuery = window.jQuery, // На это пока не обращаем внимание. // Map over the $ in case of overwrite _$ = window.$; // Вот здесь.
That is, after loading jQuery in the variable window.$ will be jQuery , and the XXX library will live in the local variable _$ the jQuery function .
That is why the documentation states that the jQuery.noConflict() method (if we want to eliminate conflicts) must be called immediately after loading the library and before using it:
In case of jQuery in your page.
That is, when we call the jQuery.noConflict() method, the following will occur:
jQuery.noConflict = function( deep ) { // Здесь будет `true`, так как у нас в `window.$` на данный момент // находится `jQuery`. if ( window.$ === jQuery ) { // Так как мы хотим исключить конфликты, то мы устанавливаем // в качестве значения переменной `window.$` сделанный ранее бэкап, // то есть возвращем исходное значение этой переменной до // загрузки `jQuery`. window.$ = _$; // Теперь в `window.$` опять живёт библиотека `XXX`. } if ( deep && window.jQuery === jQuery ) { window.jQuery = _jQuery; } return jQuery; };
With _jQuery by analogy ...
Editing and cuffing are accepted, since I just started learning jQuery and I can be wrong.