»
EnglishFrenchVietnamese

Print - Speed Up Object Detection - JavaScriptBank.com

Full version: jsB@nk » Snippet » Speed Up Object Detection
URL: https://www.javascriptbank.com/speed-up-object-detection.html

Speed Up Object Detection © JavaScriptBank.comObject 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



JavaScript
<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-->