Search code examples
htmlbrowser-syncgulp-browser-sync

Violation Avoid using document.write(). Brovser-sync issue


Had a message in console that says to avoid using document.write(). how it looks in html

Its took a while to find how to fix it or even find where problem is, couse have this part of code:

 <script id="__bs_script__">
            //<![CDATA[
            document.write("<script async src='/browser-sync/browser-sync-client.js?v=2.27.11'><\/script>".replace("HOST", location.hostname));
            //]]>
        </script>

Which appears from some library i guess (I'm didn't wrote it).

After 30min looking for that problem found that it fixes with updating browser-sync in package.json


Solution

  • To fix it by updating browser-sync, also find that useful post to update all dependencies

    How to update each dependency in package.json to the latest version