Force DOM redraw/refresh on Chrome/Mac


Every once in a while, Chrome will render perfectly valid HTML/CSS incorrectly or not at all. Digging in through the DOM inspector is often enough to get it to realize the error of its ways and redraw correctly, so it's provably the case that the markup is good. This happens frequently (and predictably) enough in a project I'm working on that I've put code in place to force a redraw in certain circumstances.

This works in most browser/os combinations: += ';-webkit-transform:rotateZ(0deg)'
    el.offsetHeight += ';-webkit-transform:none'

As in, tweak some unused CSS property, then ask for some information that forces a redraw, then untweak the property. Unfortunately, the bright team behind Chrome for the Mac seem to have found a way to get that offsetHeight without redrawing. Thus killing an otherwise useful hack.

Thus far, the best I've come up with to get the same effect on Chrome/Mac is this piece of ugliness:

    $(el).css("border", "solid 1px transparent");
        $(el).css("border", "solid 0px transparent");
    }, 1000);

As in, actually force the element to jump a bit, then chill a second and jump it back. Making it worse, if you drop that timeout below 500ms (to where it would be less noticeable), it often won't have the desired effect, since the browser won't get around to redrawing before it goes back to its original state.

Anybody care to offer a better version of this redraw/refresh hack (preferably based on the first example above) that works on Chrome/Mac?

1/12/2012 7:00:25 PM

None of the above answers worked for me. I did notice that resizing my window did cause a redraw. So this did it for me:


We recently encountered this and discovered that promoting the affected element to a composite layer with translateZ fixed the issue without needing extra javascript.

.willnotrender { 
   transform: translateZ(0); 

As these painting issues show up mostly in Webkit/Blink, and this fix mostly targets Webkit/Blink, it's preferable in some cases. Especially since many JavaScript solutions cause a reflow and repaint, not just a repaint.


This solution without timeouts! Real force redraw! For Android and iOS.

var forceRedraw = function(element){
  var disp =; = 'none';
  var trick = element.offsetHeight; = disp;

This works for me. Kudos go here.

jQuery.fn.redraw = function() {
    return this.hide(0, function() {


Hiding an element and then showing it again within a setTimeout of 0 will force a redraw.

setTimeout(function() {
}, 0);

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Email: [email protected]