Inspired by Benjamin Sterling's "Better jQuery Code" article I decided to develop a simple plugin to make his first point (Caching) easier... nothing fancy, just a few methods, but you will hopefully find it useful.

Its objective is to let you store a jQuery object with a simple key in a global cache, so that you can access the same object easily, without having to write the same selection, filtering or traversing code (i.e: $("#main < p") or $("#main").children(".selected").eq(0)).

Here is how it works:

// Store in cache - Returns current object

// Retrieve from cache - Returns cached object
$$("main_navigation"); // or jQueryCache("main_navigation");

// Remove from cache

// Clear Cache

// Load jQueryCache with noConflict to avoid overriding window.$$

There is a lot of room for improvement, which will be done depending on the feedback I get, so feel free to contact me with any ideas or corrections you might come up with.

You can get the Jquery Object Cache plugin here.