Reload CSS Bookmarklet
Nick asked me today if there was a way to just reload the stylesheets without having to reload the whole page, which can be frustrating for AJAX development. I hacked at it for a bit and stuck it on our development environment, then cleaned it up into a bookmarklet. Drag the following link to your toolbar for CSS reloading happiness & superior quality.
Update: Fixed it to work in Internet Explorer.* Turns out the original code was doing too much work, adding/removing link elements. The new code simply replaces the href attribute with a randomized value.
javascript:(function() {
var e = document.getElementsByTagName( "link" );
for( var i = 0; i < e.length; i++ )
if( e[ i ].rel.match( /stylesheet/ ) )
e[ i ].setAttribute( "href", e[ i ].getAttribute( "href" ).replace( /\?_r\=[^&]+|$/, "?_r=" + Math.random() ) );
})();
* Once. It crashes on the 2nd time, at least in IE6 SP2.
- Edit Posted February 2, 2006 at 2:33 PM PST in CSS
- Previous: Rainy Day Photos
- Next: Grasping at Air
- Leave a Comment
Comments
February 14
2:05 PM
Edit
Antony Scott writes:
Excellent little post. However, it does crash if run more than once in IE.
I really wanted this to work more than once, as it will prove really useful in my day-to-day development work.
So, i persisted and came up with a solution. I've posted an entry in my own blog.
October 18
1:34 AM
Edit
Paul writes:
Its nice really nice. I haven't seen script like this.
A good url you may check. AJAX and CSS
www.ajaxflakes.com
css 101
September 10
12:20 AM
Edit
Antony Scott writes:
I have moved my previous blog entry to here - http://blog.sixgun.co.uk/?p=25