Avoid using try...catch...finally
Avoid calls to try…catch..finally in resource-heavy areas of code (some loops, generation of complex data, etc.). When an exception is thrown, a variable (the exception itself) is created at the start of the catch clause and destroyed at the end. Creating and destroying this variable unnecessarily uses CPU power and RAM. Hence why it is important to replace this construction with a logic test as often as possible.
Cache objects repeatedly accessed by JavaScript
Accessing the DOM (Document Object Model) drains processor resources (CPU). Therefore, when you reference the same DOM element several times in JavaScript, store its reference within a variable to avoid re-parsing the DOM for the same element.