Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Preparation code goes here
- function preparationCode() {
- // code here
- // use global variable syntax because the other perf testing funcs need access
- txt = "<html><head></head><body><div id='hi' class='box'>hello world</div><p>hey</p></body></html>";
- regex = /^[\s\S]*<\s*body[^>]*>([\s\S]*)<\/body>[\s\S]*$/;
- }
- // DEFINE FUNCTION 1 HERE
- function function1() {
- var p = new DOMParser(), div;
- div = p.parseFromString(txt, "text/html");
- div.getElementById("hi").className;
- }
- // DEFINE FUNCTION 2 HERE
- function function2() {
- var text = txt.replace(regex, "$1"),
- div = document.createElement("body"); div.innerHTML = text;
- document.evaluate(".//div[@id='hi']", div, null, 9, null).singleNodeValue.className;
- }
Advertisement
Add Comment
Please, Sign In to add comment