Techno News, How To Unbrick Qualcomm Android Devices, 15 Second ADB Installer Latest Version V1.4.3 Free, Samsung FRP Reset Files Using Odin Flash, ATF Box Full Crack Tool, Facebook Contacts Sync, Miracle Box Latest Setup Full Crack Free, 4 Steps Jcow Social Networking Web Server, Infinity Box Chinese Miracle 2 MTK v 1.58 setup, Miracle Box Crack Latest Version 2.26 Full Setup, Nokia Asha 501 RM-899 Latest Flash File

Sabtu, 10 September 2016

Does 'script async' Really Make Javascript Asynchrounous?

Does 'script async' Really Make Javascript Asynchrounous? - is the information you are looking for in search engines like google and others, okay we have provided such information in the blog Techno News, we have around collecting information from various reliable sources and presenting it in this blog, well please read Does 'script async' Really Make Javascript Asynchrounous? to finish:

Articles : Does 'script async' Really Make Javascript Asynchrounous?
full Link : Does 'script async' Really Make Javascript Asynchrounous?

You can also see our article on:


Does 'script async' Really Make Javascript Asynchrounous?

You might be wondering, when Google's PageSpeed tells your website has "Render-Blocking Script". After a quick search on Google, finding similar topics on How to remove Render-Blocking Javascript, as stated by PageSpeed Insights. You would find that adding an "async" attribute to the "script" tag would do the job. But unfortunately, after all excitements, the "Don't be Evil" says the same thing again and again.



So, does adding an "async" attribute to the "script" tag really loads a javascript in an asynchronous way?

Well, as per w3cschools, "The async attribute is a boolean attribute. When present, it specifies that the script will be executed asynchronously as soon as it is available.".

Is that correct? Did you check it by yourself? - Well, for me it didn't work out, as I expected.

Here below, I've found two wonderful code snippets that would really make a javascript run asynchronous.

The traditional Javascript way

function loadScript(src, callback)
{
var s,
r,
t;
r = false;
s = document.createElement('script');
s.type = 'text/javascript';
s.src = src;
s.onload = s.onreadystatechange = function() {
if ( !r && (!this.readyState || this.readyState == 'complete') )
{
r = true;
callback();//This function will be fired, after the javascript loaded from the remote URL.
    }
};
t = document.getElementsByTagName('script')[0];
t.parentNode.insertBefore(s, t);
}

The above function will create a "script" tag dynamically and then inserts it before the first "script" tag found in the DOM(Document Object Model).

The Jquery way

$.getScript(url, successCallback);//As simple as eating an Apple pie. ;)

The above code does the same job as the first one. But, the only downfall is, you need to load the Jquery library before doing this.

Thank me for getting your PageSpeed score to the peak. :)

And, let me know your queries through the comments section.



Information about the Does 'script async' Really Make Javascript Asynchrounous? has been discussed

A few of our information about the Does 'script async' Really Make Javascript Asynchrounous?, hopefully give more knowledge for you

You have finished reading Does 'script async' Really Make Javascript Asynchrounous? and many articles about Techno News in our blog this, please read it. and url link of this article is https://ikkemunandar.blogspot.com/2016/09/does-async-really-make-javascript.html Hopefully discussion articles on provide more knowledge about the world of new tech gadgets and Techno News.

Tag :
Share on Facebook
Share on Twitter
Share on Google+
Tags :

Related : Does 'script async' Really Make Javascript Asynchrounous?

0 komentar:

Posting Komentar