Responsive iFrames with jQuery

CSS
iframe {
    max-width: 100%;
}
Javascript
function adjustIframes() {
    $('iframe').each(function() {
        var $this = $(this);
        var proportion = $this.data('proportion');
        var width = $this.attr('width');
        var actual_w = $this.width();

        if (! proportion) {
            proportion = $this.attr('height') / width;
            $this.data('proportion', proportion);
        }

        if (actual_w != width) {
            $this.css('height', Math.round(actual_w * proportion) + 'px');
        }
    });
}

$(window).on('resize load', adjustIframes);