Use Date.now() instead of new Date()
Use let instead of var for Firefox
Remove multiple var declarations by moving them to top