I will be contributing one anti-pattern here, which is a middle chain leak.
One of the strengths of jQuery is the chaining API, which allows you to continue to modify, filter, and manipulate elements:
$(".message").addClass("unread").find(".author").addClass("noob");
At the end of this chain, you have a jQuery object with all the ".message.author" elements, but this object accesses the ".message" objects and returns to them. You can get them using the .end() method and do something with them:
$(".message") .find(".author") .addClass("prolific") .end() .addClass("unread");
Now when using this path there are no problems with leaks. However, if you assign the result of a chain to a variable that has a long lifespan, backreferences to earlier sets are preserved and cannot be garbage collected until the variable goes beyond the bounds. If this variable is global, links never go beyond.
So, for example, let's say you read in one of your 2008 blog posts that $("a").find("b") was "more efficient" than $("ab") (although itβs not even worth it think about such micro-optimization). You decide that you need a global list of pages to host the authors list for you to do this:
authors = $(".message").find(".author");
Now you have a jQuery object with a list of authors, but it also refers to a jQuery object, which is a complete list of posts. You will probably never use it or even know it there, and it takes up memory.
Note that leaks can only occur with methods that select new elements from an existing set, such as .find , .filter , .children , etc. Documents indicate when a new set is returned. Simply using the chain API does not leak if the chain has simple non-filtering methods like .css , so this is normal:
authors = $(".message .author").addClass("prolific");