DEV Community

Gabriel Wu
Gabriel Wu

Posted on

Simple way to diff server/browser rendering results

I found this answer at StackOverflow. I think it is useful, so I share with you here.

Browser side

First of all, you should ensure the site is served. Then you can:

  • Open your site in any browser
  • Open the browser console, and type:
console.log(document.documentElement.innerHTML)
Enter fullscreen mode Exit fullscreen mode
  • Copy the output, and save it as client.html

Server side

Supposing your site is running on localhost:3000.

  • Open a shell, and type:
curl localhost:3000 > server.html
Enter fullscreen mode Exit fullscreen mode

Compare the differences

You can simply run:

diff client.html server.html
Enter fullscreen mode Exit fullscreen mode

Note that you may need to format both files before diff.

Top comments (0)