[ACCEPTED]-JavaScript resize event on scroll - mobile-resize

Accepted answer
Score: 54

Cache the width of the viewport and on resize 2 return false if the width is still the same.

A 1 small jQuery snippet:

    var cachedWidth = $(window).width();
        var newWidth = $(window).width();
        if(newWidth !== cachedWidth){
            //DO RESIZE HERE
            cachedWidth = newWidth;
Score: 9

Use the onOrientationChange event and the window.orientation property instead.

Also 1 see this answer.

Here link to a test page.

More Related questions