There aren’t many things I don’t like about Firefox, but there is one that constantly drives me nuts: that the View Source command actually goes back to the server to get the source of the page you’re currently viewing. Why doesn’t it just display the source from cache?

I’m sure they figure it’s the same thing, but sometimes it’s not. Take the Google X debacle. I had it still up on my screen but was unable to see the source code for the page. So I quickly wrote a little bookmarklet that would do the deed for me.

You can bookmark it directly here: View DOM Source. Remember, this only works in Firefox (or other Mozilla-based browsers).

Essentially, this bookmarklet uses the XMLSerializer object to serialize the page’s DOM representation. If the page uses little or no JavaScript, this will be essentially equal to the source. If the page’s code is modified by JavaScript, it will display the code with the modifications. Hope you all find this as helpful as I have!

Disclaimer: Any viewpoints and opinions expressed in this article are those of Nicholas C. Zakas and do not, in any way, reflect those of my employer, my colleagues, Wrox Publishing, O'Reilly Publishing, or anyone else. I speak only for myself, not for them.

Both comments and pings are currently closed.