Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Anonymous function for supportAEL isn't required #1

Merged
merged 1 commit into from

2 participants

@Daniel15

Use "not not" (cast to boolean)

@Integralist Integralist merged commit 502ec20 into Integralist:master
@Integralist
Owner

@Daniel15 thanks Daniel for flagging this up. Using the boolean coercion is a lot cleaner syntax in my opinion but I wasn't sure if it would be worse performing than a one time function execution. So I set-up a performance test case first just to be sure (http://jsperf.com/one-time-iife-or-everytime-boolean-conversion) and it was a resounding performance optimisation increase which is always nice :-)

@Daniel15

Yeah, I didn't benchmark it myself but I'd imagine that the overhead of a function call is far greater than type coercion. Function calls are relatively expensive compared to a lot of other operations. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 8, 2012
  1. @Daniel15
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 7 deletions.
  1. +1 −7 Assets/Scripts/DOMready.js
View
8 Assets/Scripts/DOMready.js
@@ -4,13 +4,7 @@ var DOMready = (function() {
var win = window,
doc = win.document,
dce = doc.createElement,
- supportAEL = (function(){
- if (doc.addEventListener) {
- return true;
- } else {
- return false;
- }
- }()),
+ supportAEL = !!doc.addEventListener,
queue = [],
exec,
loaded,
Something went wrong with that request. Please try again.