facetwp check if a facet is in use

djrmom

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