react-gist icon indicating copy to clipboard operation
react-gist copied to clipboard

Avoid using document.write()

Open Marcus-Rise opened this issue 4 years ago • 1 comments

Warning in console

index.js?c760:57 [Violation] Avoid using document.write(). https://developers.google.com/web/updates/2016/08/removing-document-write

Marcus-Rise avatar Aug 27 '20 06:08 Marcus-Rise

To add more on this, in Google's documentation there's a section on how to fix this issue:

If your provider gives you a snippet that includes the document.write(), it might be possible for you to add an async attribute to the script element, or for you to add the script elements with DOM API's like document.appendChild() or parentNode.insertBefore()

Here's an example of how Google Analytics does the injection of an external JS file:

(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
/* internal code for analytics */
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

treeindev avatar Feb 21 '22 15:02 treeindev