Using async attribute on scrip tag?

Ritchie

Posted on
May 22 2015

We have inserted raygun in a script tag on the head of the page and notice it blocking the page rendering. Would there by any issues if we add the async attribute to the script tags?


Callum

Posted on
May 26 2015

The only impact there would be at current time is that if any JS errors were thrown before Raygun4JS had been executed, these would be not be sent. Depending on what scripts are loaded in the HEAD this might not be critical, for instance if they are third party scripts or snippets e.g ga.js.

Can you provide more details on how you are loading the script and what impact it's having on rendering? If it is loaded via the CDN or you manually set the Cache-Control header the script will be cached in-browser and will not incur the request overhead. The actual execution time of the script for init().attach() should be miniscule, please let us know if this is not the case.

Depending on your exact front-end architecture another option may be to place Raygun4JS at the end of the BODY tag but above other scripts whose errors you want to catch (as all of these won't block the page load).


Ritchie

Posted on
May 26 2015

Thanks for responding.

We initially had Raygun (cdn) in the head in order to get priority loading. We also have a third party script loader placed at the top of the body. On inspection of network waterfall you could see any following scripts were blocked until Raygun was fully downloaded. So to fix this issue we replaced the inline script with script injection, as a result this does not block networking.


Reply