Cleanup JS and optimize frontend analytic polling  to avoid frequent page refreshes