Subscribe to our
weekly update
Sign up to receive our latest news via a mobile-friendly weekly email
Introducing HTML Diffs in WebPageTest. When 'Save Response Bodies' is checked, you can now explore the differences between the server-sent HTML and the final rendered HTML by the browser.
We're happy to announce the availability of a new feature: HTML Diffs. When you run a test now and you check "Save Response Bodies", a new option shows up in the drop down of results pages called HTML Diff.
It shows what changed between the page's HTML as sent by the server over the network and the HTML that the browser finally used to render the page when the test was complete. The most common reasons for there being a difference is
For the "before" HTML we get the response from the browser. For the "after" it's a bit more complicated:
The reason for the last one is to capture changes made using CSSOM (CSS Object Model), for example using insertRule(). These don't show up in outerHTML either. So a primitive CSS parsing happens to find out these. "Primitive" because we don't want to slow down the testing with a proper parsing and because it just works in most instances. If we detect that an inline CSS has changed (by counting the number of "}") we reconstruct the CSS text as a string from the CSSOM and replace the contents of the style tag, so it shows up in outerHTML and the diff. If CSS is replaced you see an extra comment at the top of the style tag saying /* inner styles set by WPT to match CSSOM */.
The browsers are extremely good at dealing with malformed HTML and making sense of it. The Prettier library we use for prettifying - not so much. As a result when you attempt to prettify before the diff, you might get an error. This uncovers malformed HTML server response and an opportunity to improve it.
It's somewhat fascinating to see how the browsers sometimes "rewrite" the HTML and where we have an opportunity to make their job easier. For example extra white space...
... or trailing slashes:
We hope you enjoy the new insights that HTML Diff can provide and find more opportunities to make your pages faster. As this is a first release of the new feature we appreciate any comments, use cases, bug reports, feedback.