Nobody wants an app that crashes or a webpage that doesn’t load, and the waiting time of the users is not very long. According to Kissmetrics, 47% of visitors expect a website to load in less than 2 seconds, and 40 percent of visitors will leave the website if the loading process takes more than 3 seconds.
With these numbers in mind, performance should always be taken into account when creating your web apps. To help get you started, here are 14 ways to effectively improve application performance:
Scripts are often used to access a certain object. By storing a repeated access object inside a user-defined variable, as well as using a variable in subsequent references to that object, performance improvement can be achieved immediately.
In order to effectively measure any improvements that you’re incorporating into your program, you must establish a set of well-defined environments where is possible to test the performance of the code.
Users want to see a page load quickly, but it’s not likely that all functions need to be available for the initial load of the page. If a user must perform a certain action in order for a function to be executed (e.g. by clicking on an element, or changing tabs), it’s possible to defer loading that function until after the initial page load.
If a memory leak is ongoing, the loaded page will reserve more and more memory, eventually occupying all the available memory of the device and severely impacting performance. You’ve probably seen (and likely been frustrated by) this type of failure, likely on a page with a carousel or image slider.
In Chrome Dev Tools, you can analyze if your website has memory leaks by recording a timeline in the Performance tab. Usually, memory leaks come from pieces of the DOM that are removed from the page but have some variable that makes reference to them and, therefore, the garbage collector can not eliminate them.
According to the Mozilla Developers Network (MDN) documentation: “Web Workers makes it possible to run a script operation in a background thread separate from the main execution thread of a web application. The advantage of this is that laborious processing can be performed in a separate thread, allowing the main (usually the UI) thread to run without being blocked/slowed down.”
Web workers allow your code to perform processor-intensive calculations without blocking the user interface thread. Web Workers allow you spawn new threads and delegate work to these threads for efficient performance. This way, long running tasks which would normally block other tasks are passed off to a worker and the main thread can run without being blocked.
Accessing the DOM is slow. If you are going to read the content of an element several times, it’s better to save it in a local variable. But it’s important to keep in mind, if you will later remove the value of the DOM, the variable should be set to “null”, so it doesn’t cause any memory leaks.
Local variables are found based on the most specific scope and can pass through multiple levels of scope, the look-ups can result in generic queries. When defining the function scope, within a local variable without a preceding variable declaration, it is important to precede each variable with
const in order to define the current scope in order to prevent the look-up and to speed up the code.
Because the scripting engine needs to look through the scope when referencing global variables from within function or another scope, the variable will be destroyed when the local scope is lost. If variables in the global scope can not persist through the lifetime of the script, the performance will be improved.
Lighthouse is a good performance tool for web pages, it helps you to audit performance, accessibility, best practices, and SEO. Google PageSpeed is designed to help developers understand a website’s performance optimizations and areas for potential improvement. The components are built to identify faults in a website’s compliance with Google’s Web Performance Best Practices, as well as automate the adjustment process.
In Chrome you can also use, the More Tools option in the main menu to see the memory and the CPU used by each tab. For even more advanced analysis, you can use the developer tools Performance view in either Firefox or Chrome to analyze different metrics, for example:
The performance analysis of devtools allows you to simulate CPU consumption, network, and other metrics while the page is being loaded, so you can identify and fix problems.
For applications built on Node.js, the NodeSource Platform is also a great, low-impact way to explore application performance at a very granular level.
Comprehensive Node.js metrics help you identify the source of memory leaks or other performance issues and resolve these issues faster.
It’s important to maintain a balance between the readability of the code and its optimization. The code is interpreted by computers, but we need to make sure that can maintained in the future by ourselves or other people, so it needs to be understandable.
And remember: performance should always be taken into account, but should never be above the detecting errors and adding functionalities.
Welcome to my Blog , In this article, you are going to learn the top 10 python tips and tricks.
#python #python hacks tricks #python learning tips #python programming tricks #python tips #python tips and tricks #python tips and tricks advanced #python tips and tricks for beginners #python tips tricks and techniques #python tutorial #tips and tricks in python #tips to learn python #top 30 python tips and tricks for beginners
I know you care about optimizing your code but sometimes you don’t know how to do it.
Imagine every piece of your code is well optimized, the performance would be great and you can easily investigate your code if having any issue.
Performance is an integral part of the Application design and plays a vital role in the success of your product/application. This is Part-2 of the performance optimization articles series. Performance optimization considerations for an enterprise-level application are discussed as part of Part-1.
Before delving into performance optimization techniques, let us discuss the factors that impact the performance of an application. Below are the most critical factors that impact the performance from my view.
This section gives you an overview of the various techniques that can be employed at various levels of your application. At a global level, below are few areas
Below are a few of the core best practices to consider as part of the user interface design and development