HTML vs XHTML Parsing Speed

Benchmark created on


Preparation HTML

<script type="text/text" id="example"><!DOCTYPE html>
<html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml" lang="en" >
	<body>
		<table class="table">
			<thead class="table-head">
				<tr>
					<th>Name</th>
					<th>Age</th>
					<th>Favourite food</th>
				</tr>
			</thead>
			<tbody class="table-body">
				<tr>
					<td>John</td>
					<td>31</td>
					<td>Beans</td>
				</tr>
				<tr>
					<td>Jeff</td>
					<td>28</td>
					<td>Bacon</td>
				</tr>
				<tr>
					<td>Douglas</td>
					<td>42</td>
					<td>Dolphin</td>
				</tr>
				<tr>
					<td>Jenny</td>
					<td>25</td>
					<td>Cheese</td>
				</tr>
				<tr>
					<td>Anna</td>
					<td>29</td>
					<td>Soup</td>
				</tr>
				<tr>
					<td>Adam</td>
					<td>50</td>
					<td>Chicken</td>
				</tr>
			</tbody>
		</table>
	</body>
</html>
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
HTML Parsing
const parser = new DOMParser();
const content = document.getElementById("example").textContent;

const doc = parser.parseFromString(content, "text/html");
ready
XHTML Parsing
const parser = new DOMParser();
const content = document.getElementById("example").textContent;

const doc = parser.parseFromString(content, "application/xhtml+xml");
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.