Fix Firefox bug in JS canvas13

Event listeners before their functions throws an error, prevents canvas
from rendering. Moved listeners below functions, all good.