Skip to content

Instantly share code, notes, and snippets.

// TODO: should probably convert result to plain array (since different engines return different things -- arrays, nodelists, objects, etc.)
var query = (function() {
var engine, engines = 'NW.Dom.select,base2.dom.querySelectorAll,Sizzle,$$,$,YAHOO.util.Selector.query,dojo.query,Ext.DomQuery.select'.split(',');
while ((engine = engines.shift())) {
if (Function('try{return ' + engine + '}catch(e){}')()) {
return Function('cssExpr, ctx', 'ctx || (ctx = document);return ' + engine + '(' +
(engine.indexOf('base2') > -1 ? 'ctx, cssExpr' : 'cssExpr, ctx') + ')');
}
}
return 'querySelectorAll' in document ?
@dperini
dperini / gist:179535
Created September 2, 2009 03:36 — forked from kangax/gist:179491
// first alert(1), then alert(2)
var foo = 1;
alert(1);
var bar = (function(){ alert(2); })();
// first alert(2), then alert(1)
var foo=1,bar=(function(){alert(2);})();alert(1);