Created
May 9, 2011 01:33
-
-
Save madrobby/961889 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// routes = [ [/test/, function(url){ console.log(url) }], ... ] | |
setInterval(function h(r){if(h.l!==(h.l=location.hash))for(r in routes)routes[r][0].test(h.l)&&routes[r][1](h.l)},10); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Well, if you don't care about overwriting events, you could drop the
addEventListener
entirely and, as long as the code runs in theDOMWindow
context, bind directly toonhashchange
. You could also save 5 more bytes by lettingh
,k
andr
leak into the global scope.Also, the semicolon is pretty pointless...