Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

livereload injection should not use document.write #6507

Closed
dashdashzako opened this issue Nov 14, 2019 · 6 comments
Closed

livereload injection should not use document.write #6507

dashdashzako opened this issue Nov 14, 2019 · 6 comments

Comments

@dashdashzako
Copy link

dashdashzako commented Nov 14, 2019

What version of Hugo are you using (hugo version)?

$ hugo version
v0.58.3

Does this issue reproduce with the latest release?

Yes

My setup

This seems to affect at least Chrome MacOS v78.0.3904.97, I have not tested other configurations.

Description of the problem

In 2016, Google had written an article called "Intervening against document.write()"
.

Unfortunately, Hugo livereload uses this function, and warnings are being shown in Chrome .

Google Chrome console screenshot

Possible solutions

As stated in the Google article:

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()

Any of these workarounds would be rather easy to add to the injection code.

@bep bep added this to the v0.60 milestone Nov 14, 2019
@davidsneighbour
Copy link
Contributor

No issues on browsers on Ubuntu 19.10. Loading hugo server site with localhost:1313 does not bring up any warnings or errors. There might be more to the explicit configuration where Chrome blocks than just "document.write()" in use. I am using (latest) Chrome 78 here.

The linked article references issues with slow networks and document.write being disabled on slow network connections. I don't see how the use of livereload is something that can end up on a slow connection?

@dashdashzako
Copy link
Author

The warning message given by the browser is very minimalist and doesn't do much beside what is in the screen capture above. The articles don't really help either, and local connection seems pretty much the opposite of slow 🤔

May be the Chrome team is expanding its document.write policy to other kind of connection, but I found no documentation anywhere talking about it.

This is the kind of ticket I could close saying "works on my setup, closing", but at least it may serve as reference if someone encounters the same problem 😄

@davidsneighbour
Copy link
Contributor

I wouldn't close it, but do you use a configuration other than localhost:1313? maybe a local ip address or a local hostname that is configured via /etc/hosts?

@bep bep modified the milestones: v0.60, v0.61 Nov 17, 2019
@dashdashzako
Copy link
Author

@davidsneighbour I'm updating the issue, there were problems due to my hugo site configuration.

However, if Chrome doesn't block the script, it still shows a warning on MacOS version 78.0.3904.97.

My apologies for the badly reported problem.

@bep bep modified the milestones: v0.61, v0.62, v0.63 Nov 25, 2019
@bep bep modified the milestones: v0.63, v0.64 Dec 11, 2019
@bep bep modified the milestones: v0.64, v0.65 Jan 22, 2020
@bep bep modified the milestones: v0.65, v0.66, v0.64 Jan 30, 2020
@bep
Copy link
Member

bep commented Jan 31, 2020

We have all of the information ready at build time (static), so I see no reason to use document.write or other client side techniques.

@github-actions
Copy link

github-actions bot commented Feb 8, 2022

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants