Defer Parsing of JavaScript

Postponing JavaScript Parsing

What it is:The “defer” tag is put inside the JavaScript code, so that the javascript files open last on the page and speed up the site.
Solution:Adding a defer tag to JavaScript codes.
Expert Comment:This issue is always a problem. It should generally be done according to the structure of the site. For example, if we want to have a loading screen when the site is opened, this script cannot be defered.

JavaScript codes have always been a problem with page speed. But; This problem can be solved by putting a “defer” tag inside the JavaScript code. With the “Defer” tag, JavaScript files will be opened last on the page, thus increasing the working speed of the site. The process of adding a “defer” tag to JavaScript codes should generally be done according to the structure of the website.

General Explanation

To load a web page, the browser must parse the contents of all “” tags, which add additional time to the page’s load time. But; Of course, the initial load time of the website can be reduced. For this, the amount of JavaScript required to create the website should be minimized. Also, unnecessary JavaScript can be parsed and delayed until it needs to be executed.</p>

Details from Google

There are several methods that can be used to delay the parsing of JavaScript. The simplest and most preferred technique is the technique to postpone JavaScript loading until needed. As a second method, it is a method to use the <script async> attribute when found appropriate. With this method, it delays the load created by the first page of the website, and prevents the browser from delaying until the UI thread is not busy doing anything else. If none of these methods are suitable for you, it is recommended to try some additional methods commonly used in the mobile apps described below.
It is important.

When creating a mobile application, it is necessary to preload all the JavaScript needed for the application, so that the application continues to work when the application user is offline. In such cases, some apps like mobile Gmail find it useful to load JavaScript in comments and then evaluate (eval ()) JavaScript when needed. This approach ensures that all JavaScript is loaded during the loading of the first page, but; It does not require parsing of JavaScript.

Storing code in literals in the avaScript string is another alternative way of storing code in comments. When using this method, JavaScript is parsed only by calling eval () in the literal string, if necessary. This method also allows the application to load JavaScript early, but delays parsing until needed.

You should note that the move of “<script>” tags to the end of the page is minimal, as the browser will continue to show a busy indicator until parsing the page JavaScript. Application users may request that the page load indicator show that the page load is complete just before interacting with the page. For this reason, it is very important for the browser to load JavaScript to maximize the time it takes to show that the page load is complete.

In early 2011 tests, on modern mobile devices, it was seen that each kilogram of JavaScript added approximately 1ms of parsing time to the total page load time of JavaScript. Therefore, 100kB JavaScript covered by the first page load creates an additional load time of 100ms for application users. Since the JavaScript needs to be parsed for each visit to a page, this extra loading time added will be part of each page loading when loaded from the network, either via the browser cache or in HTML5 offline mode.

Page Speed Terms and Solutions

Recent Articles

Russian YouTuber Has Crash (!) With Porsche Taycan Turbo S In Porsche Store

Russian YouTuber Mikhail Litvin showed in a video she recently shared with a Porsche Taycan Turbo S directly at the Porsche store. Russian YouTuber Mikhail...

Top 15 Technology Blogs for 2021

77 percent of Internet users read blogs and 23 percent of all time on the internet social networks disclose the expenditure of reading and...

Viewing Domain Records (nslookup)

Hello Media Zone Blog Readers,In this article, I will try to talk briefly and simply about the name server of the domain you have...

How to Rebuild Your Business After the COVID-19 Shutdown

The coronavirus lockdown had a devastating effect on small businesses everywhere. Even ifyou were able to adapt your business model to continue...

Computer Tech: A Secure Investment in Your Future

Choosing a career path in IT is a safe bet for a long and lucrative work life. An endless supply ofcomputer tech...

Related Stories

Your feedback is valuable to us

MediaZone - Ge the daily news in your inbox