Last Updated: February 25, 2016
·
1.814K
· wjonthomas

Change the refresh delay for Guard LiveReload

I'm using Guard with Sass and LiveReload with the Chrome LiveReload extension on a project. I was noticing that I had to hit save a couple times before the compiled CSS would be rendered. This was because my browser was refreshing before my CSS was done compiling. I went hunting for a way to fix this and discovered that there's an option called 'grace_period' in the guard-livereload documentation.

So, in your guardfile, where you set up your "watch" directories, just add the :grace_period option like so:

guard 'livereload', :grace_period => 0.8 do
  watch(%r{templates/.+\.html})
  ...
end

The value you can set is in seconds. So, 1 equals 1 second. I'm using 0.8 seconds.

Now I only have to save the file once and my code has time to compile before my browser refreshes.