Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

auto reload local html file with Live.js when change has occurred on the files

Tags:

reload

live.js sending consecutive HEAD requests to the server and if there is a change in the html, css or js file, live.js refreshing the data.

It's very simple Just link the file to the html file

<script type="text/javascript" src="live.js">

It works well if the files on a server but if I'm working on a local computer with notepad It does not work.

Does anyone know why and how to fix it?

like image 334
Dany Maor Avatar asked Oct 17 '16 14:10

Dany Maor


People also ask

How do I make HTML refresh automatically?

Approach 1: One can auto refresh the webpage using the meta tag within the head element of your HTML using the http-equiv property. It is an inbuilt property with HTML 5. One can further add the time period of the refresh using the content attribute within the Meta tag.

How do you refresh a saved page?

Reloading is triggered whenever changes are saved in the IDE, either automatically or using Press Ctrl + S on Windows/Linux, ⌘ + S on macOS, or when changes are made to a file externally.


1 Answers

In general, live.js does not support the file protocol. However, there is a very easy work-around (suggested by @MarcelValdezOrozco in a comment to this answer):

If you have Python installed, you can start a local webserver simply by running

$ python -m SimpleHTTPServer

Run it in the same directory as your HTML file. By default, the server will list the content of the directory. Navigate to your HTML. Now auto-reloading using live.js should work.

like image 150
bluenote10 Avatar answered Jan 02 '23 21:01

bluenote10