Permalink
Browse files

minor optimizations

  • Loading branch information...
1 parent 3fd8e46 commit 4c2a05a3f37aa769aa13c10df76d157f4102bba2 @HenrikJoreteg committed Jan 24, 2012
Showing with 12 additions and 12 deletions.
  1. +10 −11 &log.js
  2. +2 −1 test.html
View
21 &log.js
@@ -1,23 +1,22 @@
// follow @HenrikJoreteg and @andyet if you like this ;)
-(function (window,localStorage) {
- var out;
- if (localStorage && localStorage.debug && window.console) {
- out = window.console; // overwrite it... yeah, weird, but it works.
+(function (window) {
+ var ls = window.localStorage,
+ out;
+ if (ls && ls.debug && window.console) {
+ out = window.console;
} else {
- out = {};
- var methods = "assert,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,markTimeline,profile,profileEnd,time,timeEnd,trace,warn".split(","),
+ var out = {},
+ methods = "assert,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,markTimeline,profile,profileEnd,time,timeEnd,trace,warn".split(","),
l = methods.length,
- i = 0,
fn = function () {};
- for (; i < l; i++) {
- out[methods[i]] = fn;
+ while (l--) {
+ out[methods[l]] = fn;
}
-
}
if(typeof exports !== 'undefined') {
module.exports = out;
} else {
window.console = out;
}
-})(window, localStorage);
+})(window); // make window a local var compression optimization.
View
@@ -1,3 +1,4 @@
<!DOCTYPE html>
<title>&amp;log</title>
-<script src="&log.js"></script>
+<script src="&log.js"></script>
+<script>console.log('hello');</script>

0 comments on commit 4c2a05a

Please sign in to comment.