I searched for a solution but nothing was relevant, so here is my problem:
I want to parse a string which contains HTML text. I want to do it in JavaScript.
The fastest way to parse HTML in Chrome and Firefox is Range#createContextualFragment:
var range = document.createRange();
range.selectNode(document.body); // required in Safari
var fragment = range.createContextualFragment('html...
');
var firstNode = fragment.firstChild;
I would recommend to create a helper function which uses createContextualFragment if available and falls back to innerHTML otherwise.
Benchmark: http://jsperf.com/domparser-vs-createelement-innerhtml/3