davatron5000 / FitVids.js

A lightweight, easy-to-use jQuery plugin for fluid width video embeds.
http://fitvidsjs.com
4.77k stars 986 forks source link

Fitvid is overkill and doesn't perform well. #236

Closed native-apps closed 8 years ago

native-apps commented 8 years ago

Fitvid just isn't good sorry, it doesn't perform well and uses bad methods to fix responsive video. All video objects with height and width can very easily be calculated into ratios with less code and its 100% cross browser ready and doesn't rely on absolute positions and prepending a wrapper lol. It's really becoming a nuisance having to deregister this script from plugins in WP, time after time.... :(

Here is a simple yet fast solution. (Of-course you'' want to target your objects & iframes by their attributes.) function resizeIframes() { $("iframe, video, .anything").each(function() { var ratio = $(this).attr('height') / $(this).attr('width'); $(this).css('height', $(this).width() * ratio); }); } $(window).on("load resize",function(e) { resizeIframes(); });

davatron5000 commented 8 years ago

Sorry you're upset. While your feedback could have been a little bit more constructive, I appreciate your solution but will decline. FitVids employs a CSS based intrinsic resizing technique, not window.resize, which has its own problems.