var hasQSA = (function() { var div = document.createElement('div'); div.innerHTML = "<p class='TEST'></p>"; if (!div.querySelectorAll || div.querySelectorAll(".TEST")|0) return 0; div = null; return 1; })(); alert(hasQSA);