inject platform.js in head and remove unused templates