Move infinite scroll code into external JS, set current page and total pages variables in the theme