How to write performant JavaScript code