facelessuser / MarkdownPreview

Markdown preview and build plugin for Sublime Text https://facelessuser.github.io/MarkdownPreview/
Other
407 stars 53 forks source link

With LiveReload enabled Chrome shows console error on markdown preview #60

Closed derwok closed 5 years ago

derwok commented 5 years ago

Hi,

TL;DR I'm sending a PR on this.

I'm using newest version of LiveReload & MarkdownPreview. After enabling LiveReloads 'Simple Reload', then generating the preview HTML from my markdown, Chrome shows the following error in the console:

14:31:04.213 39.html:1106 A parser-blocking, cross site (i.e. different eTLD+1) script, 
http://localhost:35729/livereload.js?snipver=1, is invoked via document.write. 
The network request for this script MAY be blocked by the browser in this or a 
future page load due to poor network connectivity. If blocked in this page load, 
it will be confirmed in a subsequent console message. 
See https://www.chromestatus.com/feature/5718547946799104 for more details.

(anonymous) @ 39.html:1106

The cited line HTML number has this code:

document.write('<script src="http://' +  (location.host || 'localhost').split(':')[0] +
  ':35729/livereload.js?snipver=1"></' +'script>')

StackOverflow says Chrome now mandatory needs async with document.write: https://stackoverflow.com/a/39610983

I tried a local fix inside markdown_preview.py and the error is gone, while the live reload functionality is still working.

So, I'm sending a PR soon... Thanks for your work in this cool Plugin!