Ahmad's Blog

Ahmad's pic

Hi, My name is Ahmad Aroyehun.
A Junior Frontend Developer hungry to learn more, Find more about me

Ahmad's Blog

High Performance Javascript.

Blog Pic

Common JavaScript performance problems#

The first step to fixing any problem is identifying the root cause. Here are a few things that can cause JavaScript performance to falter:

1. Too many interactions with the host# Every interaction with the host object, or the user's browser, increases unpredictability and contributes to performance lag. This problem often manifests as slow rendering of DOM objects. You obviously can't avoid such interactions, but you can keep them to a minimum. Learning more about what can contribute to blocking the DOM and how to fix it.
2. Too many dependencies# If your JavaScript dependencies are plentiful and poorly managed, then your application's performance will suffer. Your users will have to wait longer for objects to render, which is especially annoying for mobile users with limited bandwidth.
3. Poor event handling# Proper use of event handlers can improve performance by reducing the depth of your call stack; however, if you don't keep track of them, they can execute repeatedly without your knowledge. Use them sparingly and wisely.
4. Inefficient iterations# Since iterations take up so much processing time, they provide a great starting point for optimizing your code. Removing unnecessary loops or calls within loops will speed up your JavaScript performance.
5. Unorganized code# JavaScript's loose nature is both an asset and a liability. You can do a lot with just a small subset of lexical constructs, but a lack of organization in your code can result in inadequate allocation of resources. Familiarizing yourself with ECMA standards can help you construct more concise JavaScript.

Source: https://www.keycdn.com/blog/javascript-performance