Set JS counter in the <head> section of your HTML

OR enqueue in Wordpress functions.php