Firebug Tutorial – Logging, Profiling and CommandLine (Part II) 22

Firebug Tutorial

Section 1: Console Tab : Logging, Profiling and CommandLine (Part II)


This tutorial is the part II of “Firebug Tutorial – Logging, Profiling and CommandLine“. (If you haven’t read the part I of this tutorial, I would recommend you to read the part 1 first.)

The following topic will be covered in this section.

  • Javascript Profiler
  • Tracing error
  • Tracing XmlHttpRequest object

#1. Javascript Profiler

Javascript Profiler is very useful feature of Firebug for measuring the execution time of each javascript code. It is useful for improving the performance of your code or if you wanna find out why a particular function takes soooo long. It is a bit similar to console.time() that I mentioned already to previous part but Javascript Profiler can give you more detailed information about what’s happening with your code.

There are three ways to use Javascript Profiler. You can call this function by clicking “Profile” button on the toolbar of Firebug console or through code “console.profile()” or by typing “profile()” in commandline. I will cover first two in this tutorial but not for using profile() in commandline. If you want to know how to use it in commandline, please check-out this article.


  • Copy and paste the code in notepad and then, save as a htm file
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="" >
<script language="javascript" type="text/javascript">

function startDoSomething(){
<strong>console.profile('Measuring time');</strong>
function doSomething(){

function doThis(count){
for(var i=0;i&lt;count;i++){}

function doThat(count){
for(var i=0;i&lt;count;i++){}

function doThisAndThat(countThis,countThat){
for(var i=0;i&lt;countThis;i++){ for(var j=0;j&lt;countThat;j++){} }
Open the console tab. Click the button below and wait a lit.. <br />
<input type="button" value="Start" onclick="startDoSomething();"/>
  • Open this file in Firefox browser.
  • Open the Console tab on Firebug console.
  • Click “Start” button and wait a lit.. (You will get the result like the screenshot below. )


(The list is sorted based on the execution time.)

Columns and Description of Profiler

  • Function column : It show the name of each function.
  • Call column : It shows the count of how many a particular function has been invoked. (2 times for doThis() function in our case. )
  • Percent column : It shows the time consuming of each function in percentage.
  • Own Time column : It shows the duration of own script in a particular function. For example: doSomething() function has no its own code. Instead, it is just calling other functions. So, its own execution time will be 0ms as shown in picture. If you wanna see some values for that column, add some looping in this function.
  • Time column : It shows the duration of execution from start point of a function to the end point of a function. For example: doSomething() has no code. So, its own execution time is 0 ms but we call other functions in that function. So, the total execution time of other functions is 923 ms. So, it shows 923 ms in that column. Not clear? Feel free to let me know. I can try once more.. I don’t mind to explain you again. (That’s my problem in writing .. I can’t write very clear.. Sorry about that. )
  • Avg column : It shows the average execution time of a particular function. If you are calling a function one time only, you won’t see the differences. If you are calling more than one time, you will see the differences. Take a look the doThis() function at second line of picture above.
    The formula for that column is ~
    Avg = Own Ttime / Call;
  • Min column and Max column: It shows the minimum execution time of a particular function. In our example, we call doThis() function twice. When we passed 1000 as an parameter, it probably took only a few millisecond. (let’s say 1 ms.). then, we passed 100000 to that function again. It took much longer than first time. (let’s say 50 ms.) . So, in that case, “1 ms” will be shown in Min column and “50 ms” will be shown in Max column.
  • File column : the file name of file where the function located.

Note: You can set the title of profiler by passing one string to console.profile() function. In our example (console.profile(‘Measuring time’);), ‘Measuring time’ is the title of profiler.
Profiler button from Console tab’s toolbar

If you don’t want to profile thru the code, you can use “Profile” button from the toolbar of Firebug console.


In order to test this,

  • you need to remove two lines (console.profile(‘Measuring time’); and console.profileEnd();) from doSomething() function.
  • Open this file in Firefox.
  • Open Console tab of Firebug console.
  • Click “Profile” button ( right button on the toolbar of Firebug console.)
  • Click “Start” button on your page.
  • Wait for 1 min ( or a lit less than that.)
  • Click “Profile” button again. ( You will get the same graph as the picture above.)

That’s all about Javascript Profiler. Let me know if you have any question or comment.

Okay. Let’s move on to next topic.

#2. Options of Console tab

There is one link called “Options” at the right-side of Firebug console. If you click this link, you will see the menu as shown in picture below.


I will divided those times in three categories.

  1. Errors Tracing
    1. Show Javascript Error
    2. Show Javascript Warnings
    3. Show CSS Errors
    4. Show XML Errors
  2. XmlHttpRequest Tracing
    1. Show XMLHttpRequests
  3. CommandLine
    1. Larger Command Line

#2.1 Errors Tracing and Filtering

  • Show Javascript Errors
  • Show Javascript Warning
  • Show CSS Errors
  • Show XML Errors

Those options are used for tracing the errors of your script, style sheet and XML. You can also filter the error messages based on the type of error that you wanna.

Example Code

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="" >
<style type="text/css">
bcolor : red;  /* This is ERROR!! */
<script language="javascript" type="text/javascript">
function foo(){
var objTxt = doucmnet.getElementById('nameTextBox');  //This is ERROR!!

<input id="nameTextBox" class="normalText" type="text" />
<input type="button" value="Start" onclick="foo();"/>

Output ~


  • Copy and paste the code in notepage.
  • Save as a .htm file.
  • Check “Shows Javascript errors” and “Shows CSS errors” on Console tab.
  • Reload the page
  • First, you will get the CSS error. ( Reason : We wrote bcolor instead of color in “normalText” class. )
  • Click the button
  • then, we will get the another error. ( because we wrote “doucmnet” instead of “document” in the code. )

I think those options are very sample to use. If you wanna see the errors, just check the option in menu. then, Firebug will give very good information about the errors that you are getting. Uncheck it if you don’t want.

#2.2. Tracing XmlHttpRequest object

This is also one of the most popular feature of Firebug and it is really helpful for Ajax developer. The problem with Ajax is that it is very difficult to figure out if something goes wrong in XmlHttpRequest. Sometimes, you have no idea about what’s going on behind the sense while the indicator keep on cycling all the time. One of the problem that I face when I was playing around with ajax, it is difficult to find out whether the response format from Web service are correct or not.

but things are very simple with Firebug. You only need to select “Show XmlHttpRequest” option. Firebug will tell the following thing.

  1. The execution time
  2. Parameters (QueryString)
  3. HTTP Header
  4. Response

Example : I used Yahoo UI DataTable in this sample. This sample is the updated version of this sample from Yahoo UI.

Download : SourceCode

  • Download the zip file from the link above
  • Extract the zip file and put all files to PHP directory.
  • Try to call this file “dt_xhrlocalxml_clean.html” from Firefox ( http://localhost/yui-php/dt_xhrlocalxml_clean.html in my case.)
  • Open the Console tab in Firebug console.
  • Select “Show XmlHttpRequests” option
  • Click the button “Load Data” on the page
  • The following result as shown in picture will be shown. (The style might be a lit bit different since I didn’t change the path in some CSS files. )


  • And check the Console tab in Firebug console.
  • You will the detailed response in XML format as shown in the picture below.


Note: If you don’t wanna download or if you don’t have PHP installed on your machine, you may try to check this online sample from Yahoo. But there won’t be any button so you should select the “Show XmlHttpRequests” option first and reload or open the link…

Okay. That’s all for today. I was thinking to write about CommandLine in this part but I don’t have the enough time to write it today. Don’t worry. I will tell about CommandLine tomorrow.

Cya. Don’t hesitate to drop a comment if you have any suggestion or comment. I appreciate it.

22 thoughts on “Firebug Tutorial – Logging, Profiling and CommandLine (Part II)

  1. Reply Myo Kyaw Htun Sep 11,2007 1:21 am

    congrats! Mike, your first firebug tutorial has been featured in popular page :D

  2. Reply Michael Sync Sep 12,2007 1:52 am

    thanks. man.. I think people don’t like part II… I’m not sure why…
    What do you think about part II??

    Is the content not interesting? or Is my writing boring? or Is that too complex? or does everybody already know about this feature???

  3. Reply Myo Kyaw Htun Sep 12,2007 9:25 am

    I don’t think so, both of part 1 and 2 are informative. May be, they think that no need to save part 2 link coz part 1 that links to part 2.
    I don’t know what the other people think.

  4. Reply kangax Sep 13,2007 3:55 pm

    As far as writing style, part 1 is definitely better (what’s with all these “wanna” ? )
    Great content is good, but making it sound interesting is even better, don’t you think? : )


  5. Reply Michael Sync Sep 13,2007 4:53 pm

    Hi kangax,

    Thanks.. .

    You are right. I will review my post this weekend and will update it..

  6. Pingback: Quest's Blog

  7. Pingback: links for 2007-10-02 « Simply… A User

  8. Pingback: Michael Sync » Firebug Tutorial : Section 4 - Net, CSS and DOM tabs

  9. Reply Anoymous Mar 25,2008 2:18 pm

    Great tutorial! I appreciate that English is not your first language, and you have done a great job of communicating nonetheless, but perhaps you have a friend/colleague who could correct the grammar for you? This would really increase the value of this tutorial for users I think, and in fact I would say make this the best study guide for Firebug on the web! :-)

    Great work.

  10. Reply Michael Sync Mar 27,2008 9:28 am


    >>Great tutorial! I appreciate that English is not your first language, and you have done a great job of communicating nonetheless,

    Thanks. :)

    >>but perhaps you have a friend/colleague who could correct the grammar for you?

    Yes. I wish I have one. but it’s hard to find someone who like to help in correcting grammar or etc.. Actually, I’m so boring to learn English. I learnt English from Movies, Email and other people’ blogs.. Learning English is not like learning programming. so, it’s not just interesting. If English were Programming, I would probably know a lot of languages. :)

    However, I wish some of my readers will correct me if they found something wrong in my article. If you found something incorrect or something, feel free to let me know. I really appreciate it.


  11. Pingback: Transmissão de Conhecimento, usando a função dir do Firebug « Anselmo

  12. Pingback: Scrabble Yabble - Aleem Bawany

  13. Pingback: 【周报】20090606 | 天机不可泄漏

  14. Pingback: Firebug 及yslow的相关资料 | 出家如初,成佛有余

  15. Pingback: 关于firebug和yslow的资料汇总帖 | 出家如初,成佛有余

  16. Pingback: Optimizing JavaScript | dtsn

  17. Reply fijiwebdesign Mar 9,2010 11:00 am

    Thanks for the great explanation on profiler. Don’t worry, your explanations are very clear :)

    A typo on ” what’s going on behind the sense”. Should that be “scenes”?

  18. Pingback: Application profiling and performance optimization using Firebug - StrategyBeach

  19. Reply Danielle Oct 18,2010 5:08 am

    3 years later this is still useful :)

  20. Reply web Sep 7,2011 11:35 pm

    Very good article. very clear expanation..thanks a lot for your info.. keep posting

  21. Reply Richard Harrington Oct 27,2011 8:56 pm

    I am reading your Firebug tutorials because they were assigned to me for a class in Javascript. I think they’re great. I agree, I think your English is easy enough to read, but if you want me to correct it, I will be happy to do this for you. I’ll just make static html copies of your pages, with the text converted into my suggested corrections, and I’ll host them on my server and you can cut and paste the html if you want. Do you have any interest in that?

  22. Pingback: jQuery: dicas de otimização e performance | Tableless

Leave a Reply