Skip to main content
JavascriptSnippets

Force Reload CSS Locally

By January 5, 2020April 11th, 2020No Comments

I often run into caching issues and fight the browser and / or server to give me the latest revision of a stylesheet. This is one of the most frustrating complications in my line of work as a developer / designer. I found this awesome write-up on force reloading CSS locally!

The author includes a bookmarklet and the source so it can be implemented on a site. I personally decided to use this on my network in a modal window alongside other links like admin login and troubleshooting 🙂

Just drop this into an anchor link and you’re set!

javascript:(function(){var h,a,f;a=document.getElementsByTagName('link');for(h=0;h<a.length;h++){f=a[h];if(f.rel.toLowerCase().match(/stylesheet/)&&f.href){var g=f.href.replace(/(&|%5C?)forceReload=\d+/,'');f.href=g+(g.match(/\?/)?'&':'?')+'forceReload='+(new Date().valueOf())}}})()

Contact us to learn more about Adopt the Web for your business

Author Jarod Thornton

More posts by Jarod Thornton