facetwp check a single facet

djrmom

{{gist file=”facet.js” lang=”javascript”}}
<script>
(function($) {
/**
* check if a facet exists but is empty, change ‘categories’ to name of the facet being checked
*/
$(document).on(‘facetwp-loaded’, function() {
if (‘undefined’ !== typeof FWP.facets[‘categories’] && FWP.facets[‘categories’].length < 1 ) {
// do something if facet is empty
}
});
})(jQuery);
</script>
{{/gist}}