updating template and JS loading logic