facetwp scrollTop example with wp_head hook

<?php
/** adds script to header 
 ** https://facetwp.com/how-to-add-pagination-scrolling/
 **/
add_action( 'wp_head', function() { ?>
	<script>
		(function($) {
			$(document).on('facetwp-loaded', function() {
				if (FWP.loaded) {
					$('html, body').animate({
						scrollTop: $('.facetwp-template').offset().top
					}, 500);
				}
			});
		})(jQuery);
	</script>
<?php } );