When developing new websites, one of the worse things is that you always have to refresh the whole page to see some minimal changes made on an external .css file. Sometime ago I have found one small peace of script that forces the website to just update the CSS code.
It work this way: Even in localhost or on a remote host, when you make some changes just on the CSS file, and press F5 in any browser, you have to download all the xhtml and images again. When you are working with an remote server, this is one of the worst things, and takes some seconds of your precious time! To improve that you should bookmark a small JavaScript code in to your Firefox toolbar, and when you want to update just the CSS style you press it. The script deletes the css file from your cache, re-opens the website cached and with the CSS file updated. This way is way faster!
To create this button you should click with right mouse button on your “bookmark toolbar” in Firefox. In the menu you should choose “New BookMark”; insert some name, like “CSS Refresh” and in “location” paste this code:
javascript:void(function(){var i,a,s;a=document.getElementsByTagName('link');for(i=0;i<a.length;i++){s=a[i];if(s.rel.toLowerCase().indexOf('stylesheet')>=0&&s.href) {var h=s.href.replace(/(&|%5C?)forceReload=d+/,'');s.href=h+(h.indexOf('?')>=0?'&':'?')+'forceReload='+(new Date().valueOf())}}})();
Now, everytime you’re in Firefox making some changes on your CSS code, just press the button to update your style sheet.
Thank you very very much!! Been looking for something like this for a very long time!! I’m a webdesigner who constantly rams on the F5 key in my Mozilla alike webbrowers. Reduces server load and saves time when pages load slowly.
Now if something like this would work for Internet Explorer (6 or 7)? Tested the same trick but didn’t work.
What a nice piece of code!
For some reason my browser shows quotes with another symbol, I’ve rewritten it:
javascript:void(function() {var i,a,s;a=document.getElementsByTagName(‘link’);for (i=0;i=0 && s.href) {var h = s.href.replace(/(&|?)forceReload=d /,”);s.href = h (h.indexOf(‘?’)>=0 ? ‘&’:’?’) ‘forceReload=’ (new Date().valueOf());}}})();
Blessings!
I was looking for solution to this problem.
If you are on windows, you may want to try XRefresh (http://xrefresh.com). Version 0.7 supports fast update of CSS files as a reaction to filesystem change to some of these CSS files.
Just got a new laptop, downloaded Mozilla and pages keep constantly refreshing themselves!!! Can’t open some pop-up windows because they again constantly refreshing themselves and don’t even let me get into them HELP!! Explore is working normal
Päivää anna, every page is refreshing? Are you sure it isn’t a virus?
There are some virus that won’t let you open firefox, so you must use IE. Try installing some anti-virus 🙂
oh f*.. you daniel, really. i was looking for this on google and found your page.. haha :)) :)) thanks a lot :))
Fantastic tip! I actually went ahead and packaged this into a Firefox extension. This has saved me stupid amounts of time already. Kudos!
Extension is here: https://addons.mozilla.org/en-US/firefox/addon/7465
@cemre LOL!
@Chris Heald Well done! Thanks for linking 🙂
Even better: CSS Sync – still in experimental stage, but rocks!
CSS Sync: https://addons.mozilla.org/en-US/firefox/addon/6784
this works.
javascript:void(function(){
var i,a,s;
a=document.getElementsByTagName(‘link’);
for(i=0;i=0&&s.href){
var h=s.href.replace(/(&|?)forceReload=d /,”);
s.href=h (h.indexOf(‘?’)>=0?’&’:’?’) ‘forceReload=’ (new Date().valueOf())
}
}
})();
I ran into the same “symbols” problem because of wordpress “smart quotes” and for somereason firefox does like a urlencode() on it. So i’ll try pasting it in the <pre> element trying to avoid smart quotes.
javascript:void(function(){var i,a,s;a=document.getElementsByTagName(‘link’);for(i=0;i=0&&s.href) {var h=s.href.replace(/(&|?)forceReload=d /,”);s.href=h (h.indexOf(‘?’)>=0?’&’:’?’) ‘forceReload=’ (new Date().valueOf())}}})();
sorry that was mispasted:)
for(f=0; f= 0 && stylesheet.href) {
var h = stylesheet.href.replace(/(&|?)forceReload=d /,”);
stylesheet.href = h (h.indexOf(‘?’)>=0?’&’:’?’) ‘forceReload=’ (new Date().valueOf());
}
}
}
sorry i give up; pointed braces got deleted, and i dont want post more junk just to figure out the the rules:-/
Not working at all mate..Then i pressed this nothing happened..pfff