Full version: jsB@nk » Snippet » Speed Up Object Detection
URL: https://www.javascriptbank.com/speed-up-object-detection.html
Object detection is common in JavaScript. Browser irregularities mean that your code must sometimes contain branches for different browsers. Use this JavaScript snippet to perform object detection once instead of every time you call addEvent.
Full version: jsB@nk » Snippet » Speed Up Object Detection
URL: https://www.javascriptbank.com/speed-up-object-detection.html
<script type="text/javascript"><!--/* Created by: Dean Edwards :: http://dean.edwards.name/Licensed under a Creative Commons License */var addEvent;if (document.addEventListener) { addEvent = function(element, type, handler) { element.addEventListener(type, handler, null); };} else if (document.attachEvent) { addEvent = function(element, type, handler) { element.attachEvent("on" + type, handler); };} else { addEvent = new Function; // not supported}//--></script><!-- This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->