Update metronome.js

Made some several optimizations