HTML5 Canvas performance: low-level optimization tips and tricks
elekslabs.com
elekslabs.com
If you are interested, I have a decently quick floodfill here. Might be worth a benchmark but never got around to it: https://gist.github.com/4071852
Another thing is, this stuff can easily be thrown into a webworker, which will definitely help with some more complicated fills on larger canvases.
EDIT: If you're micro-optimizing, why not cache '((hitColor >> 24) & 0xFF)' in a local at the top of the function instead of computing it every iteration? Loop invariant code motion might hoist it for you, but I don't know why you wouldn't do that by hand.
Also, wrapping your integer arithmetic in ( ) | 0 may improve its performance in Firefox and some other browsers because it allows the JIT to omit overflow checks. Should help since you're doing a lot of addition to index into arrays.
my nightly FF does in 500ms what FF16 does in 250ms and chrome does in 200ms :(