The jQuery home page contains several blocks of code that use $
, such as the following.
$( "button.continue" ).html( "Next Step..." )
However, no where on that page or in the jQuery API Documentation page does it say what $
means in this context.
This makes understanding jQuery very difficult and in some case it makes it impossible.
I am asking this question because I need to resolve an issue in a browser extension I am responsible for maintaining but I am not certain how. The issue I need to resolve is related to the following line of code.
$(document).on('DOMNodeInserted', InspectPage.OnNodeInserted);
This line of code causes the following warning.
Listener added for a synchronous 'DOMNodeInserted' DOM Mutation Event. This event type is deprecated (https://w3c.github.io/uievents/#legacy-event-types) and work is underway to remove it from this browser. Usage of this event listener will cause performance issues today, and represents a risk of future incompatibility. Consider using MutationObserver instead.
When researching how to resolve this issue I found the Mutation events will be removed from Chrome page that contains the following code block.
// Replacement mutation observer code:
const observer = new MutationObserver(mutationList =>
mutationList.filter(m => m.type === 'childList').forEach(m => {
m.addedNodes.forEach(doSomething);
}));
observer.observe(target,{childList: true, subtree: true});
I know that for my purposes I need to replace doSomething
with InspectPage.OnNodeInserted
. The problem is that I do not know what to replace target
with when adding the above code to my extension because the jQuery documentation does not bother to explain what $
is. Since I do not know what $
is, I also do not know what $(document)
is.