1

I know How do I make Firefox auto-refresh on file change? but here I have another specific requirement:

How to make Firefox (or, if not possible with it, let's say Chrome) auto-refresh on HTML file change, even with the file:// protocol?

Context: I'm working on a simple HTML + CSS only page. I'm used to not launch a server for such simple tasks, and I'd like to avoid it.

A solution did exist in the past (with a browser extension), that I used even in the case of a local page file:///D:/Documents/page.html, but I can't find it anymore.

Basj
  • 41,386
  • 99
  • 383
  • 673
  • Same question (except it's not Firefox only) [javascript - How do I make a local HTML page auto-refresh on file change? - Stack Overflow](https://stackoverflow.com/questions/48858760/how-do-i-make-a-local-html-page-auto-refresh-on-file-change) – user202729 May 14 '22 at 13:18

1 Answers1

-1

This answer does NOT use the file:// protocol.

Access to the file protocol is restricted by browsers for security reasons, but if you really need the functionality and have npm installed, simply install the live-server package and it will serve the purpose.

There maybe different tools that do this, but I personally use live-server. live-server "..is a little development server with live reload capability. Use it for hacking your HTML/JavaScript/CSS files..."!

After installing the package, run the "live-server" command in your project directory and it will load the file in the browser automatically. It will watch the file for changes and refresh the page on any change.

Read more here: https://www.npmjs.com/package/live-server

Zabeeh Khan
  • 196
  • 1
  • 11
  • Thank you for your answer. But as stated in the question, this is a requirement : "not launch [...] I'd like to avoid it.". Else, I already know how to use a python of php server for example. But here I'd specifically want to avoid it. – Basj Jan 14 '19 at 12:32
  • Well, I am not sure if that is possible anymore. I just read that the Auto Reload extension for Firefox did the job but it's no longer supported. – Zabeeh Khan Jan 15 '19 at 07:22
  • Yes, AutoReload, that's it! It seems no longer available. For such local dev, I should just download a portable version of FF 56 (or at least < 57, pre-FF Quantum ), and find this deprecated extension AutoReload again (that was so useful and so handy!). – Basj Jan 15 '19 at 07:31
  • That will do the job. Good luck. – Zabeeh Khan Jan 15 '19 at 07:40
  • I don't find AutoReload anymore, do you know where it could be archived @ZabeehKhan? – Basj Jan 15 '19 at 07:56
  • I just did a quick search buddy and found this archive: https://github.com/JustOff/ca-archive and this http://livereload.com/extensions/ . Please have a look if these can help. – Zabeeh Khan Jan 15 '19 at 11:54
  • What is your use case by the way? Why would you want to so strictly stick with the file: protocol? and why only FireFox? – Zabeeh Khan Jan 15 '19 at 11:55
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/186710/discussion-between-basj-and-zabeeh-khan). – Basj Jan 15 '19 at 13:03
  • From http://livereload.com/extensions/, 1) the Chrome version doesn't work (I tried it, and it hardcodes checking on 127.0.0.1, which I don't want). 2) the FF version is outdated: https://addons.mozilla.org/en-US/firefox/addon/livereload/ (`Oops! We can’t find that page`). – Basj Jan 15 '19 at 13:08