js code consolidation