As we all know, creating a website is now an easy task that anyone can do, whether using free tools with easy-to-understand functions, taking a short time to learn, or using paid tools with more comprehensive features. Both of these formats do not necessarily require coding knowledge. However, what is worrying or often overlooked is the efficiency of the resulting website, which is not as good as expected. In other words, the website is slow and sluggish. The question is, how can we speed up the website? Because remember that page loading has become an important factor for Google to rank websites. Above all, let’s first understand that a website consists of HTML + CSS + JavaScript + Other Assets. Therefore, if you want to improve the website’s loading speed, it must be said that there are many techniques, some of which are easy to do and some are difficult because they require some coding knowledge.
However, in a new video from Google Developer Advocate Alan Kent, he shares 4 ways to optimize JavaScript to improve website performance. Kent pointed out the problems that often arise from JavaScript along with basic troubleshooting methods. What are the details? Let’s see together.
1. Reduce the Number of JavaScript Files
The easiest way is to avoid adding too many JavaScript files to your website. Of course, if the website has too many JavaScript files, especially in the UI components, it will cause more problems. Therefore, reducing the number of JavaScript files that the browser needs to download will definitely help improve the website’s speed.
How to Check if There Are Too Many JavaScript Files
If you suspect that your website may have too many JavaScript files, you can try using tools like Google’s PageSpeed Insights by entering the URL of the website you want to check.
Then the system will display details and provide recommendations to follow. As in the example figure
How to Fix It
There are many ways to solve this problem. One method recommended by Google is to combine different files into one file, or if you don’t want to combine files, simply add HTTP2 to the website, which will immediately improve the website’s performance.
2. Remove Inefficient JavaScript Files
For websites with inefficient JavaScript files, it can also result in a slow or sluggish website, directly affecting the user experience.
How to Check
You can check for inefficiencies on your website through Google PageSpeed Insights. When the system detects JavaScript files that may negatively affect the website, various details will appear as follows:
- Eliminate Render Blocking Resources This recommendation reports about JavaScript files that, when a website is accessed, the browser loads by reading the code from top to bottom. But while loading, if it encounters CSS or JavaScript files, it will stop reading and analyze which part of the web the file will be used in before proceeding to load the webpage. These scripts will slow down the page loading.
- Document.write JavaScript files with Document.write will delay page loading for more than 10 seconds, which significantly affects website downloading.
- Does not use Passive Listeners For Javascript files that may cause abnormalities with scrolling performance.
How to Fix It
The techniques for solving problems related to inefficient JavaScript files will vary depending on the causes mentioned above. For example, if you find that your website has too many Document.write files, causing lag, just try to remove the code with Document.write.
3. Remove Unused JavaScript Files
Another common problem with websites is having too many unused JavaScript files. Repeatedly calling code results in the website wasting resources by downloading files unnecessarily.
How to Check
You can check for problems on Google’s PageSpeed Insights as follows:
- Reduce unused JavaScript This report shows JavaScript files that are not used.
- Avoid enormous network payloads This is a common problem with websites with long content, as it makes the website use more resources, causing the webpage to lag or slow down.
- Minimize main-thread work Every time a website is opened, a thread is created, called the Main-Thread or UI Thread. This is the thread that communicates with the user, consisting of HTML, CSS, and JavaScript. If the Main Thread takes too long to work, it may result in slow page loading.
How to Fix It
Try removing unnecessary CSS and JavaScript to make the website load faster. Because before the website is finished loading, it must go through the process of loading unused files, which will make the website loading slower.
4. Compress JavaScript Files
Don’t forget to always ensure that JavaScript files are compressed to make the files smaller and able to load faster, reducing the number of files the browser needs to download and reducing the number of files to process, resulting in faster website rendering.
How to Check
On Google’s PageSpeed Insights, enable the function to recommend file compression. Then the system will display a list of which JavaScript files need to be compressed.
How to Fix It
Most browsers or CMS (Content Management System) often have features to notify users which files should be compressed, or choosing to use plugins that help compress files can also be used.
Get Digital Marketing Consulting from Relevant Audience
Relevant Audience is a company providing services related to Digital Performance Marketing Agency, with the main goal of providing digital marketing services to businesses to reach target audiences who are looking for products or services at the right time, place, and device through online channels. Our services cover both Search Marketing, Social Media Ads, Search Ads, and SEO (Search Engine Optimization) to Influencer Marketing and is also part of the Google Partners program.
For more information
Tel: 02-038-5055
Email: info@relevantaudience.com Website: www.relevantaudience.com