improve performance of DOM.parseTemplate