browser-sync: Snippet can't be loaded from server

scr_2015-08-27_03-41-12_pm

<script type='text/javascript' id="__bs_script__">//<![CDATA[
    document.write("<script async src='http://HOST:3000/browser-sync/browser-sync-client.2.8.0.js'><\/script>".replace("HOST", location.hostname));
//]]></script>

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 34 (12 by maintainers)

Most upvoted comments

Adding my experience with this issue and what so far has become my workaround…

Starting with a fully working app that uses browser-sync with no issues. I make a copy of this working go-to starter kit project, change minor textual issues (project name, etc.) and run the app in development mode, where index.html loads with no problem, until about a week ago and every time since – the start page in the browser-sync development server, has a 404 for browser-sync-client.2.8.2.js – as mentioned by others above.

After days of hunting this down and following various false leads, unsuccessfully, I did something similar to what I see suggested in a comment above: Before the closing </body> tag of my start page I manually entered:

<script async="" src="/browser-sync/browser-sync-client.js"></script>

Subsequent loading of the start page, no longer contains the 404, the page and site run without issues and the following code gets inserted as the first lines after the opening <body> tag:

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

Next, I remove the script tag I manually entered. The very next run of the app and the start page load, everything works correctly, no 404s and the same lines as above are inserted into the document.

So my workaround is to manually enter the script once that references browser-sync-client.js no version, load the site. close the site, remove the manually entered script, and from then on everything is fine.

This feels like somehow a reference to 2.8.2 is cached or lying around somewhere, that after manually entering the client script reference, it flushes that, and thereafter the correct script reference gets inserted.

Any updates on this issue or know of a better workaround, I see a reference to using the scriptPath option?

Can you run it again, then try http://localhost:3000/browser-sync/browser-sync-client.js in a browser…