|
|
Subscribe / Log in / New account

The Grumpy Editor encounters Firebug

Benefits for LWN subscribers

The primary benefit from subscribing to LWN is helping to keep us publishing, but, beyond that, subscribers get immediate access to all site content and access to a number of extra site features. Please sign up today!

By Jonathan Corbet
August 28, 2007
Part of the LWN Grumpy Editor series.
Those who have been paying close attention may have noticed a number of changes to the LWN site over the last few weeks. Most of those changes are not visible; our quaint early-90's table-oriented HTML is slowly giving away to a more contemporary design which makes use of the features of cascading style sheets. This sort of work involves a lot of change-and-reload cycles in an effort to figure out why something is not rendering as your editor intended. CSS is a powerful but sometimes obscure technology. One tool your editor wishes he had stumbled across earlier is Firebug, a Firefox extension designed to help with just this sort of work.

Firebug can be thought of as a sort of interactive debugger for HTML and CSS. It is not an authoring tool; it is assumed that content is being created by other means. It is, instead, a way of figuring out why things look the way they do and how to make them come out better.

[html inspector] To that end, Firebug includes an interactive HTML inspector. It's a sort of "view source" window, but done in a much more useful way. By using the "inspect element" option in the Firefox content menu, a web developer can find the HTML for a specific item in a hurry. The display of the document tree is hierarchical, making it easy to see how elements relate to each other. Editing of element attributes is a matter of clicking on them and entering new values; numeric attributes can also be adjusted up and down with the arrow keys. As a result, it is easy to make quick HTML changes and immediately see what the results are.

It is also possible to edit the text contained within the elements, but the interface is somewhat awkward. But this is not a functionality which really matters anyway; Firebug is about markup and rendering, not the content itself.

Positioning the mouse over an element in the HTML inspector highlights the corresponding part of the displayed document. This feature can be useful in correlating the two windows, but it also leads to extensive flashing and blinking as the mouse moves through the window. Something a little less distracting and gaudy would be more to your editor's taste.

The HTML inspector also features a pane which shows the stylesheet entries relevant to the element of interest. The entire cascade is shown, with overridden attributes marked. As a result, it is easy to see where all of the rendering parameters for an element are coming from. Anybody who has worked with CSS for a while knows that the combination of selection rules and cascading can lead to mysterious effects at times. The CSS display removes the mystery, making the source of strange behavior obvious. Once again, CSS parameters can be tweaked on the fly, making it easy to adjust attributes until things fit together just right. One shortcoming here is that adding new attributes does not appear to work in any useful way; it seems that attempts have been made to support this functionality, but your editor was unable to make it work.

[Layout display] There is a separate "layout" display which shows how the various parts of the CSS box model come together in the rendering of a specific element. The values of the margin, border, and padding attributes can all be adjusted on the fly, and a set of rules shows how each plays into the final positioning of the element on the page. Your editor, who has often used the old trick of turning on borders to see how an element has been placed, likes this display better: it separates out the effect of the various attributes and does not, in itself, change the rendering. So questions like "where is that extra white space coming from?" are easily answered. One complaint here is that changing the border parameters is pointless if border style is none (which is the default); it would be nice to be able to play with border styles in the same place.

Finally, there is a mode for playing with stylesheets as a whole. In this mode, the entire stylesheet is available and attributes can be tweaked to see what their effect is on the page as a whole. There is a toggle for every attribute allowing it to be turned off. New attributes can be added - that feature seems to work on this screen. What is missing is any way to save the results of changes.

[Timings display] For those who are concerned with page load times, there is a mode which shows, in bar-graph form, just how long each component of the page took to load. It is possible, in each case, to look at the request and response headers associated with that loading. This feature is probably not one which will be heavily used by most web developers, but it can be useful if a specific page is loading slowly for any reason.

LWN is not a site which makes much use of Javascript, so your editor has not played with the Javascript-specific features of Firebug. Those features look impressive, though. There is a complete interactive debugger, a profiler, a DOM inspector, and more. The HTML inspector, unlike the Firefox "view source" feature, shows what the document's HTML looks like after it has been mangled by Javascript code. All told, it looks like a nice package for those doing that kind of work.

"View source" has always been a fundamental part of how web pages are designed. So it is not surprising that Firebug supports this mode of operation very well. But trying to figure out how a CSS designer got a specific effect from the standard "view source" screens is, with modern pages, often a painful experience. Firebug takes a lot of the pain away by making it easy to look at specific elements and the CSS declarations which affect them. In general, Firebug is a tool which gives a highly useful view into just how the browser is rendering a document. It has become an important part of your editor's toolbox.


(Log in to post comments)

The Grumpy Editor encounters Firebug

Posted Aug 28, 2007 19:09 UTC (Tue) by lacostej (guest, #2760) [Link]

Firebug is one of the best web developer tool out there.

Some of my preferred other extensions for web development: selenium-ide (for automated testing), web developer and greasemonkey.

Enjoy the ride.

And good to head the LWN is getting a facelift :)

The Grumpy Editor encounters Firebug

Posted Aug 28, 2007 23:23 UTC (Tue) by sayler (guest, #3164) [Link]

ditto on selenium IDE + Firebug! Great development tools! (I wish firebug had been around the last big CSS project I did -- or that it's JS debugger was around on my last JS project.)

Oh well!

The Grumpy Editor encounters Firebug

Posted Aug 29, 2007 1:25 UTC (Wed) by Mithrandir (guest, #3031) [Link]

Firebug is (like so much other OSS) an evolution of the existing tools. Venkman (JS debugger) has been around since the early mozilla suite days, as has the DOM inspector. The only bit that's really new is the CSS inspection feature, and a whole bunch of polish.

A great tool... I use it in combination with the web developer toolbar.

Aardvark, Web Developer, GreaseMonkey

Posted Aug 28, 2007 19:39 UTC (Tue) by shapr (subscriber, #9077) [Link]

Aardvark, Web Developer, and GreaseMonkey are other web developer tools that I strongly recommend.

The Grumpy Editor encounters Firebug

Posted Aug 28, 2007 19:40 UTC (Tue) by pj (subscriber, #4506) [Link]

Relatedly, the Grumpy Editor should maybe take a look at Platypus (http://platypus.mozdev.org/) which adds a bit of WYSIWYG to GreaseMonkey, allowing you to reformat your favorite sites the way you like them: hate fixed-width columns? need to change colors because you're colorblind? etc etc.

Platypus

Posted Aug 28, 2007 19:48 UTC (Tue) by corbet (editor, #1) [Link]

Platypus was reviewed just over two years ago.

The Grumpy Editor encounters Firebug

Posted Aug 28, 2007 19:50 UTC (Tue) by leonscape (guest, #12261) [Link]

As I've ended up being a web developer, Firebug literally saves me hours
of time.

You've mentioned the CSS, but the real star is the Javascript debugger.
Without it I would of given up on some things, and it's what led me to
firebug in the first place.

Its got everything you'd expect, breakpoints, variable watching, and the
DOM inspector is a really useful tool to see what's really going on with
all those properties, its also useful to just look to see what's
available.

Firebug should be on anyone's list if their thinking about doing anything
with HTML, CSS or Javascript.

The Grumpy Editor encounters Firebug

Posted Aug 28, 2007 19:56 UTC (Tue) by vmole (guest, #111) [Link]

The Cranky Reader wishes you posted this about two weeks ago...but at least I'll know about it the *next* time I go into battle^W^W^W work with CSS.

The Grumpy Editor encounters Firebug

Posted Aug 28, 2007 20:14 UTC (Tue) by JoeF (guest, #4486) [Link]

I had the same reaction... I could have put this to good use.
Thanks to Jon for the pointer.

The Grumpy Editor encounters Firebug

Posted Aug 28, 2007 20:06 UTC (Tue) by frazier (guest, #3060) [Link]

This is nice article. I've had Web Developer in use before and liked it. I'll have to give Firebug a try.

I start designing web pages in Photoshop. I'll then build it largely by hand (with some ImageReady in there if needed). I find that spending more time upfront in Photoshop and less time "designing" in html/css gives better results in less time.

-Brock

(posting this in part to see what my user ID# is)

The Grumpy Editor encounters Firebug

Posted Aug 28, 2007 20:53 UTC (Tue) by bronson (subscriber, #4806) [Link]

Photoshop can be a time saver IF you're familiar with the limitations of HTML and CSS. I've had ex-print designers come up to me with mockups and I'd have to explain, "This flow would take days to lay out and won't work in all browsers, and this rounded liquid area over here is flat out impossible." Burns up a lot of time until they get a feel for what's reasonable.

The Grumpy Editor encounters Firebug

Posted Aug 28, 2007 23:24 UTC (Tue) by frazier (guest, #3060) [Link]

Very true. I started with HTML so it is easy for me, but I know what you're talking about. I worked in an ad agency for awhile in 1999-2000 and some of the things the graphic artists would hand over were not practical to implement (this was the IE3/NS4 days so there was a lot of rendering errors and limitations) or usable on a screen since they were still composing with a print mindset.

Photoshop makes it far easier to try effects and scale things than trying to do it while coding up a page. As you mention, knowing the limitations is very helpful.

The Grumpy Editor encounters Firebug

Posted Aug 28, 2007 23:06 UTC (Tue) by evgeny (subscriber, #774) [Link]

> (posting this in part to see what my user ID# is)

Could see it from your previous comments, "My Account"->"Comments you have posted".

The Grumpy Editor encounters Firebug

Posted Aug 30, 2007 4:02 UTC (Thu) by midg3t (guest, #30998) [Link]

I wonder if it's really worth publishing user ID numbers alongside the comments. I don't understand what it gains, aside from the tiny possibility of reducing the ability to impersonate a user by using a similar name.

The Grumpy Editor encounters Firebug

Posted Aug 30, 2007 7:31 UTC (Thu) by evgeny (subscriber, #774) [Link]

Well, I like this feature - one easily sees who's a senior subscriber and who isn't ;-) B. boards typically list user's join date. Consider this an equivalent.

The Grumpy Editor encounters Firebug

Posted Aug 30, 2007 14:36 UTC (Thu) by nix (subscriber, #2304) [Link]

I'm not sure what it gives you other than a warm fuzzy feeling, though: for it to mean anything more you'd need to know the subscriber signup rate (should I be scared that I first thought 'first derivative of signups with respect to time'?)

The Grumpy Editor encounters Firebug

Posted Aug 30, 2007 14:47 UTC (Thu) by evgeny (subscriber, #774) [Link]

I get a zero-order approximation by knowing the date the LWN subscriptions began and my own subscription date and #; first order corrections might be made based on occasional Jon's statistics reports ;-)

The Grumpy Editor encounters Firebug

Posted Aug 28, 2007 20:42 UTC (Tue) by egoforth (subscriber, #2351) [Link]

I've been waiting for an appropriate place to be able to comment on this, but I have appreciated the gradual "freshening" of the site over the past few weeks. I especially like the new appearance of the partial comment borders and the author attribution blocks.

Favorable remarks

Posted Aug 28, 2007 23:36 UTC (Tue) by ncm (guest, #165) [Link]

In my experience, favorable, non-snarky remarks are always appreciated at lwn@lwn.net, even when followed (as I seem unable to resist) by suggestions for improvements. That address, by the way, is also the best place to mention typos; if you add a comment about a typo, then they fix it, the comment just confuses subsequent readers.

Favorable remarks

Posted Aug 29, 2007 2:24 UTC (Wed) by maney (subscriber, #12630) [Link]

Speaking of making suggestions...

Much of the cause of typo corrections in comments is, I'm sure, just that posting a comment is the tool that's right there when you notice the error; the better (in most respects) out of band method isn't. Heck, I've been reading since LWN had the emphasis on "weekly" (IIRC there would be only the rare, really really timely items posted outside of the schedule) and I'd have to poke around to find the correct email address. Although I am, perhaps, eccentric in that I don't have an email facility directly attached to the browser, even a mailto: link that I can't use directly would be an effective reminder. A "report errors" link to a form might be preferred for spam abatement measure, though I have to doubt that the email address isn't already in their lists.

The Grumpy Editor encounters Firebug

Posted Aug 28, 2007 21:23 UTC (Tue) by NightMonkey (subscriber, #23051) [Link]

Using Firebug and Web Developer together is a powerful HTTP/HTML/CSS debugging combination. These tools allow you to get the most out of your browser, as well as debug complex sites and web-facing applications. Don't want a cache in Firefox? Turn it off via Web Developer's Disable -> Disable Cache. Don't want to tell sites where you've been? Disable -> Disable Referrers. And the features which allow you to easily see the impact of CSS element definitions are just awesome. Once you use them, you won't know how you got along without them.

The "Net" page of Firebug is quite nice for tracking down certain kinds of site performance issues - very much like the latency data presented by Keynote System's (proprietary) HTTP response time measurement tools - without all the data center POPs, of course...

A suite of tools that every SysAdmin with web-based applications to maintain should have.

Yahoo Firebug demo on video

Posted Aug 29, 2007 5:59 UTC (Wed) by roelofs (guest, #2599) [Link]

Joe Hewitt gave an excellent presentation/demo of Firebug at Yahoo back in January. A brief description, together with a Flash-embedded video and links to a higher-quality, downloadable, MP4/Quicktime version and to a blogged synopsis, are all here:

http://yuiblog.com/blog/2007/01/26/video-hewitt-firebug/

Greg

The Grumpy Editor encounters Firebug

Posted Aug 29, 2007 9:49 UTC (Wed) by nedrichards (subscriber, #23295) [Link]

For more performance oriented stuff try YSlow [http://developer.yahoo.com/yslow/] which is a plugin for Firebug (yes, plugins have plugins now) from Yahoo (MPL/BSD licensed) that I've found really helpful.

The Grumpy Editor encounters Firebug

Posted Aug 30, 2007 17:45 UTC (Thu) by jwb (guest, #15467) [Link]

Don't you find YSlow's advice somewhat coarse? It tells me that I should use Akamai for my 13KB static HTML page with no external elements. In fact it gives my site an "F" for not using Akamai!

The Grumpy Editor encounters Firebug

Posted Aug 30, 2007 4:03 UTC (Thu) by midg3t (guest, #30998) [Link]

> This sort of work involves a lot of change-and-reload cycles in an effort to figure out why something is not rendering as your editor intended.

That was cleverly ambiguous ;)

The Grumpy Editor encounters Firebug

Posted Oct 3, 2007 2:02 UTC (Wed) by hugh (guest, #928) [Link]

A useful addition to Firebug is YSlow. Like the Net tab in Firebug, it analyzes the page load time, but it also provides suggestions on how to make the page load faster and estimates how much of the page will be loaded from cache.


Copyright © 2007, Eklektix, Inc.
This article may be redistributed under the terms of the Creative Commons CC BY-SA 4.0 license
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds