The Daily WTF
Dave does a little work on a website when the core developers are in over their heads on maintenance. Which is a thing that happens a lot.
Let’s see if we can get a sense of why, starting with this little method here:
function check(cssclass, csschange) { if($(cssclass).length) { console.log(cssclass + ” does exist “); csschange(); } else { console.log(cssclass + ” does not exist, waiting…”); setTimeout(function() { check(cssclass, csschange); }, 250); } }
The check function accepts a query selector (it’s called cssclass but any DOM query selector would work here), and csschange, which is a callback function. If that selector finds one or more elements, we log that it exists and invoke the callback. If it doesn’t, we set a timeout and check again, four times a second.
Presumably, the purpose of this is to fire an event after a certain set of DOM elements are available
To read the full article click on the 'post' link at the top.