Automatically refresh browser in response to file system changes?
Asked Answered
B

2

2

When doing web development, you frequently make changes and then refresh the browser. Is there an easy way to have a daemon listening for changes in the filesystem, and when there is one, to send a refresh message to Firefox or Safari?

This would really improve your workflow and focus. You could keep your browser running in a separate screen, and when you're working on UI related changes, it would automatically refresh as you're working.

It would be like using autotest when doing TDD. (See http://github.com/svoop/autotest-fsevent)

Has anybody done this?

Bugs answered 22/7, 2010 at 13:55 Comment(0)
B
6

I can think of a way to do this for Firefox. You install the MozRepl plugin. You can then have it start up and telnet to port 4242 (by default) and control the browser via. Javascript commands. Issuing a BrowserReload() will reload the current tab.

Now, add an editor hook to do that when any files in the current project are saved and it'll be taken care of. I believe there are some snippets around that already do this.

I don't use Safari or Chrome too much so I don't know about options there.

Also, I'm not sure this is a good idea really. I don't want my browser to refresh on every file save. I usually make a bunch of changes to the backend, css and maybe even images and then when I'm ready, reload the browser tab. It's not per save. Anyway, this will do what you want.

Bromism answered 22/7, 2010 at 14:29 Comment(1)
What's nice about the emacs integration is it can be by file type. So if you're tweaking CSS or HTML files, it will update as you work on the file. It's not always a good idea to do this. But if you're doing a lot of work on front-end changes, I can see this being quite handy. The main benefit, I believe, is increased focus. It doesn't seem like a big deal to switch, but I've seen what a difference autotest makes in TDD, and sometimes something like this can have a significant impact. Noufal, thank you!Bugs
A
0

From the browser no, not really possible as far as I know. You could add a interval javascript to refresh the page every x-seconds. But to be honest, isn't Ctrl+R suitable enough to see changes?

Anthracosis answered 22/7, 2010 at 14:16 Comment(1)
I know that I'm quite partial to [F5].Determinant

© 2022 - 2024 — McMap. All rights reserved.