Simple way to diff server/browser rendering results
Gabriel Wu

Gabriel Wu @lucifer1004

About: A writer. Writing academic papers, blogs, codes, documents, essays, novels, poems, and translations.

Location:
Beijing
Joined:
Dec 29, 2018

Simple way to diff server/browser rendering results

Publish Date: Feb 24 '19
5 0

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.

Comments 0 total

    Add comment