facetwp redirect on refresh

<?php
/** adds script to header 
 **/
add_action( 'wp_head', function() { ?>
	<script>
		(function($) {
        $(document).on('facetwp-refresh', function() {
            if (FWP.loaded && 'recipes' != FWP_HTTP.uri) { // if not the initial pageload, and we're on the homepage
                window.location.href = '/recipes/?' + FWP.build_query_string(); // redirect
            }
        });
    })(jQuery);
	</script>
<?php } );