facetwp alt check for empty

<?php
/** check facets and hide if empty **/
add_action( 'wp_head', function() {
	?>
		<script>
		(function($) {
			$(function() {
			FWP.hooks.addAction('facetwp/loaded', function() {
				$('.facetwp-facet').each(function() {
				var content = $(this).html();
				var $parent = $(this).closest('.widget');
				('' == content) ? $parent.hide() : $parent.show();
				});
			}, 1000 );
			});
		})(jQuery);
		</script>
	<?php
}, 100 );