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

Domain and Corona Virus

Hello GuysAfter the coronavirus started, many domain investors started registering domains related to corona.According...

Superconductors and Superconductor Physics 2020

You plug the cable into the wall socket and run the device by passing the electric current through...

How to Write SEO-Friendly Articles 2020

What is an SEO Friendly ArticleIt draws an increasing graph in the right proportion...

New Release of The Witcher 3 Redux – Free Download

A new version of The Witcher 3 Redux Mod has been released by a modder. The new version...

Worm Manure (Vermicompost) – 2020

Worm manure production can be initiated with large-scale commercial thinking, as well as the increasing number of red...

Related Stories

Your feedback is valuable to us

MediaZone - Ge the daily news in your inbox