Join Now! It's FREE. Get full access and benefit from this site
Thursday, 18 June 2009 16:05
Firebug is one of the most popular tools used by web developers. In this article, we’ll take a closer look at ten of its most attractive features.
The first thing you’re going to notice when opening Firebug (either from the
status bar or using the ctrl+F12 key combination) will be the Console panel. After a quick look, one might think that it is an alternate version of the Error Console
(Ctrl+Shift+J). Common features between the two are:
But Firebug extends the Firefox functionality, so it can do
much more, such as:
Let’s look over some examples built upon the console object. Imagine running the
following HTML file.
<html>
<head>
<script type="text/javascript">
console.time(1);
console.log('the script section has started executing');
console.warn('warning message');
console.error('error message');
console.info('info message');
console.log(
'finishing script execution\n',
'execution took:'
);
console.timeEnd(1);
</script>
</head>
</html>
This will generate the following result.
The second panel, and the one in which I’m sure you’re going to spend a lot
of time, is split among several sections which we will review below.
The main difference between this panel and the Style section under HTML is
that here you can work on uncomputed styles. I’ll outline and number the sections
(and features this time).
Sometimes, when writing Javascript code, you have to get your hands
dirty. Most of the time, you’ll find yourself working with the
Console panel; only in extreme conditions will that make you jump to the Script
panel. Given those extreme conditions (which are bound to happen), let’s review this panel, and start familiarizing ourselves with it.
The same as HTML->DOM. Given the fact that nothing differs from what was mentioned before, we’ll skip to the next section.
Curious how long your page took to load? Or do you
want to know which request takes the most time to complete? Thankfully, this, too, can be accomplished via the Net panel.
Need to test the performance of a specific function or loop? Use the Firebug’s “timer” feature.
function TimeTracker(){
console.time("MyTimer");
for(x=5000; x > 0; x--){}
console.timeEnd("MyTimer");
}
Three step. We begin by calling “console.time” and pass in a unique key. Next, we insert our code. Finally, we call console.timeEnd, and once again, pass in our unique key.
This is an additional panel provided by CodeBurner, a Firebug
add-on. As its name states, through this panel you’ll have quick access to your HTML
and CSS code. Even if the panel is self-explanatory, we will still look over
it.
If you’ve ever done PSD slicing, you know how time consuming the measurement
of spacing in between composition elements can be. That’s where PixelPerfect proves it’s
power. Having this add-on in your toolbox will help you perform the perfect slice.
Another Firebug add-on developed by Yahoo!, which can suggest speed improvements
based on a series of tests performed.
Through YSlow, we can grade our website’s overall performance. We can easily
spot issues which can be improved, and a series of recommendations are available
as well.
Apart from the pie charted statistics, we also have JSLint and Smush.it at our disposal.
Our last, but not least, important Firebug component is FirePHP. With this
add-on, we can transparently send information (warnings, errors, logging, info)
to the Console panel from our PHP code. Example usage from FirePHP’s website:
<?php
FB::log('Log message');
FB::info('Info message');
FB::warn('Warn message');
FB::error('Error message');
?>
I hope this small list of Firebug panels/add-on will make your life as a
web person easier — as it did to me. In the end, we all know that
bugs are bound to happen, so there’s no excuse for not being prepared.
Follow these links to download the add-ons: