View DOM Source Bookmarklet
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.




4 Comments
Comments are now fixed!
Nicholas C. Zakas on March 17th, 2005 at 5:10 pm
Seriously, folks, the comments are fixed.
Nicholas C. Zakas on March 18th, 2005 at 7:55 pm
Finally!
José Jeria on March 20th, 2005 at 10:06 am
If you select some or all of what's displayed in a web page (with firefox) there is an additional entry in the right click menu (View Selection Source) which does basically the same thing as the bookmarklet (without a bookmarklet).
Jeremy Fujimoto-Johnson on April 13th, 2005 at 1:39 pm
Comments are automatically closed after 14 days.