Created
August 21, 2014 23:34
-
-
Save haggen/c8dd092f19e5d6a58553 to your computer and use it in GitHub Desktop.
Auto refresh CSS on Rails+turbolinks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
<%= javascript_tag do %> | |
// Auto refresh CSS every 2s, only on development, turbolinks ready | |
!this.REFRESHER && (this.REFRESHER = setInterval(function() { | |
$('link[rel="stylesheet"]').attr('href', function(index, value) { | |
return value.replace(/\?.+|$/, '?' + Math.random()); | |
}); | |
}, 2000)); | |
<% end if Rails.env.development? %> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment