Refactor js code for handlebars ajax badge processing.