Define variables locally
When you call a function, the variables used to describe it are stored within. Variables are divided into two categories.
Local variable: – Variables that are defined only within themselves.
Global variable: – Variables that are only described within themselves are referred to as local variables.
Variables that are used in the script are referred to as global variables.When you call a function, the browser performs a task known as scope lookup. When the number of scopes in the scope chain grows, so does the amount of time it takes to access variables that aren’t part of the current scope.
This is why it takes a longer time for an engine to access a global variable than it does a local variable. This means that if you identify the majority of variables locally, the time it takes the engine to check for them would be significantly reduced. As a result, the application’s average pace will improve.
Keep codes light and small
It’s important to keep mobile app code as light and lightweight as possible in order to retain high performance. Keeping the code light and small will help to minimise latency and increase speed.
You should ask yourself the following questions when you’re in the creation stage.
- Do I really need this module?
- Can I do this in a simpler manner?
- Why am I using this framework?
- Is this worth the overhead?
Event Delegation implementation
Event delegation allows you to use a single event controller, which aids in the efficient handling of a specific form of event across the entire page. Due to the presence of multiple event handlers, large web applications can stop if Event Delegation is not used. Event delegation has a number of advantages, including less functionality to handle, less memory to store, and less connections between DBAs.
Avoid unwanted loops
Minimize DOM access
Boost performance by caching object
Refrain from using too much memory
Implement the various optimizations
You must always use the algorithms with the least computational complexity to solve all tasks with optimal data structures.
- By rewriting algorithms, you can achieve the same results with fewer calculations.
- Recursive calls should be avoided.
- Calculations, calls, and variables for all the repeated functions should be entered.
- Make mathematical calculations easier to understand.
- Instead of using a case statement or a switch, use search arrays to get a value that is dependent on another.
- Take advantage of speculative execution of processor by generating conditions that are likely to be valid.
I am raw html block.
Click edit button to change this html