I was using:
.fb-comments, .fb-comments span, .fb-comments iframe[style] {
width: 100% !important;
}
To make Facebook Comments responsi
The debounce solution from Ka. is good but this could be more straightforward and should memoize the nodes. Make sure you wrap your fb-comments in some container:
Then (if using jQuery) setup a resize that debounces the number of requests. Also, make sure you cache the nodes you are checking to speed things up:
var $comments = null;
var $fbComments = null;
var resizeTimeout = null;
function resizeComments() {
if (resizeTimeout) clearTimeout(resizeTimeout);
resizeTimeout = setTimeout(function() {
resizeTimeout = null;
if (typeof FB === 'undefined') return;
// The class of the wrapper element above is 'comments'
$comments = $comments || $('.comments');
$fbComments = $fbComments || $(".fb-comments");
if ($comments.width() !== parseInt($fbComments.attr("data-width"), 10)) {
$fbComments.attr("data-width", $comments.width());
FB.XFBML.parse($comments[0]);
}
}, 100);
}
Then call this function on document ready and when the window resizes:
$(document).ready(function() {
resizeComments();
$(window).resize(function() {
resizeComments();
});
});