Joined July 2012
·

Seán Hayes

Rochester, NY
·
·
·

Don't forget about Silver Searcher:
sudo apt-get install silversearcher-ag

It lets you do ag foo, which is roughly equivalent to find -type f|xargs grep foo, but executes way faster.

Posted to jQuery DOM cache object over 1 year ago

How about something like:

$C = (function($){
    var DOMCACHESTORE = {};

    return function(selector, force) {
            if (DOMCACHESTORE[selector] !== undefined && !force) {
                return DOMCACHESTORE[selector];
            }

            DOMCACHESTORE[selector] = $(selector);
            return DOMCACHESTORE[selector];
        }
})($);

Then you can replace all your "$('h1')" with "$C('h1')", which is a lot less to type than "DOMCACHE.get('h2')".

Achievements
76 Karma
0 Total ProTip Views