<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>The True Tribe &#187; Firebug</title>
	<atom:link href="http://www.thetruetribe.com/tag/firebug/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.thetruetribe.com</link>
	<description>Vroom! That&#039;s us leaving IE in the dust.</description>
	<lastBuildDate>Fri, 22 Jan 2010 23:34:03 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Firebug Tutorial: Getting Started</title>
		<link>http://www.thetruetribe.com/2008/03/firebug-tutorial-getting-started/</link>
		<comments>http://www.thetruetribe.com/2008/03/firebug-tutorial-getting-started/#comments</comments>
		<pubDate>Fri, 21 Mar 2008 12:58:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[debugging]]></category>
		<category><![CDATA[Firebug]]></category>
		<category><![CDATA[Firefox]]></category>

		<guid isPermaLink="false">http://wordpress.thetruetribe.com/?p=3</guid>
		<description><![CDATA[Firebug is a plugin for Firefox that greatly aids CSS and JavaScript debugging. This guide will walk you through installing Firebug and using some of its functionality, including debugging JavaScript, inspecting the DOM and editing CSS on the fly.

Getting Started
First, make sure you&#8217;re running Firefox. If you aren&#8217;t, get Firefox now. You won&#8217;t be disappointed. [...]]]></description>
			<content:encoded><![CDATA[<p>Firebug is a plugin for Firefox that greatly aids CSS and JavaScript debugging. This guide will walk you through installing Firebug and using some of its functionality, including<span style="font-weight: bold;"> debugging JavaScript</span>, inspecting the DOM and<span style="font-weight: bold;"> editing CSS on the fly.<span id="more-3"></span><br />
</span></p>
<h4>Getting Started</h4>
<p>First, make sure you&#8217;re running Firefox. If you aren&#8217;t, <a title="Firefox really is the best browser." href="http://www.getfirefox.com/">get Firefox</a> now. You won&#8217;t be disappointed. Next, <a href="https://addons.mozilla.org/en-US/firefox/addon/1843">install Firebug</a> by following the link and clicking &#8220;Install Now.&#8221; After installing, restart Firefox and continue.</p>
<p>Now you can click the small icon in the bottom right corner of the Firefox window to open Firebug. Go ahead and open it&#8211; the first time running, you may have to choose to enable it for sites on the world wide web.</p>
<p><a href="http://www.thetruetribe.com/uploaded_images/html1-770907.gif" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"><img style="cursor: pointer;" src="http://www.thetruetribe.com/uploaded_images/html1-770892.gif" border="0" alt="" /></a></p>
<h4>Using the Console</h4>
<p>The first tab that&#8217;s open in Firebug is the console. The console tab shows JavaScript error messages, as well as having a command line interface (CLI) where you can enter JavaScript and execute it in real time.</p>
<p><a style="margin: 10px 0pt 10px 10px; float: right;" href="http://www.getfirebug.com/cl.html"><img class="miniscreen" src="http://www.getfirebug.com/screenHome-cl.gif" alt="" /></a>Using the CLI, you can call functions, define variables, or even write new functions.</p>
<p>The JavaScript error messages are are also helpful for debugging since they show you which line the error occurred on, as well as a <a href="http://en.wikipedia.org/wiki/Stack_trace">stack trace</a>.</p>
<p>Another interesting feature is the ability to <span style="font-weight: bold;">log messages to the console </span>by using the method <span style="font-style: italic;">console.log()</span>. Note that this will throw an error in browsers which don&#8217;t have Firebug installed, so it&#8217;s just for development purposes.</p>
<p>Logging messages can be very useful when debugging complex JavaScript applications that have a lot of moving parts. It can also be used for page profiling. Here&#8217;s an example of how you might use logging to the console to add some <span style="font-weight: bold;">rudimentary speed profiling</span> of a JavaScript function:</p>
<pre class="js:nocontrols">function doStuff() {
var startTime = new Date().getTime(); // The current time in epoch milliseconds

// Add code here to be profiled

var endTime = new Date().getTime() - startTime;
console.log("The function doStuff() took " + endTime + " milliseconds to complete.");
}</pre>
<p>This would result in a message being logged to the console with the amount of milliseconds it took for that code to execute. Nothing fancy, but it gets the job done!</p>
<h4>DOM Inspection</h4>
<p>Clicking the next tab over in Firebug, to <span style="font-style: italic;">HTML</span>, you&#8217;ll find a two-paned window that allows you to browse the DOM on the left and edit CSS on the right.</p>
<p>Start opening HTML tags and mousing over them. You&#8217;ll notice that the HTML element on the screen lights up when you hover over the tag. It&#8217;s a nice feature that lets you quickly orient yourself in the code.</p>
<p>The highlighted area also shows how much space an element is taking up on the screen. The color blue denotes the element&#8217;s <span style="font-style: italic;">height</span> and <span style="font-style: italic;">width</span>, while yellow is <span style="font-style: italic;">margin</span> and purple is <span style="font-style: italic;">padding</span>.</p>
<p>Clicking the <span style="font-style: italic;">Inspect</span> button (next to the bug icon in the top left corner of Firebug) will toggle a mode where you can click on HTML elements on the screen and it will go to that tag in the code.</p>
<p>There&#8217;s another tab for DOM inspection, the aptly-named <span style="font-style: italic;">DOM</span> tab. Here you will find all of the DOM objects created by JavaScript, such as <span style="font-weight: bold;">variables and functions</span>, as well as the <span style="font-weight: bold;">core DOM API</span> (for example, the <span style="font-style: italic;">window</span> and <span style="font-style: italic;">document</span> objects can be inspected here).</p>
<p>I check this page when I want to view the current state of the page and watch it change as JavaScript executes. For example, say I have a variable that keeps track of how many items are in a shopping cart. I could watch this variable in the <span style="font-style: italic;">DOM</span> tab to make sure that it&#8217;s incremented when I add an item to the cart.</p>
<h4>Editing CSS on the Fly</h4>
<p>Going back to the <span style="font-style: italic;">HTML</span> tab, notice that the pane on the right shows CSS styles for whichever element is currently selected. You can choose an element in the left pane (or by clicking <span style="font-style: italic;">Inspect</span> and then clicking the element), and the CSS styles for that element will be displayed. Furthermore, you can edit the properties and even add new ones.</p>
<p>Firebug has a different take on CSS editing than some other debugging programs, namely the <span style="font-weight: bold;">Microsoft Web Developer Toolbar</span>, so I&#8217;ll clarify how it works: In Firebug, when you change a CSS style, it updates it for every element on the page. Conversely, in Microsoft Web Developer Toolbar, changing CSS styles only affects the currently selected element.</p>
<p>By way of example, say you have the CSS rule <span style="font-style: italic;">p {padding: 10px;}</span>. You then select a P tag and change it to <span style="font-style: italic;">padding: 20px</span>;<span style="font-style: italic;"> </span>using Firebug<span style="font-style: italic;">. </span>The result is that every P tag will now have 20px padding, unlike other programs where it would only affect the styles of the selected tag.</p>
<p>To add a new style, simply click twice in the whitespace inside of a style block, next to the existing declarations. Firebug even has a convenient auto-complete feature for writing CSS.</p>
<p>In the right page, there are three tabs: <span style="font-style: italic;">Style, Layout </span>and <span style="font-style: italic;">DOM</span>. So far, we&#8217;ve been editing CSS in the <span style="font-style: italic;">Style</span> tab, but make sure to check out the other two as well. The <span style="font-style: italic;">Layout</span> tab offers an alternate view of the box model for the selected element, along with pixel-precise measurements of its dimensions. The <span style="font-style: italic;">DOM</span> tab shows all properties and methods for that element.</p>
<h4>Page Profiling and Network Metrics</h4>
<p><a style="margin: 10px 10px 10px 0pt; float: left;" href="http://www.getfirebug.com/net.html"><img class="miniscreen" src="http://www.getfirebug.com/screenHome-net.gif" alt="" /></a>Nothing&#8217;s worse than making a great site only to have it suffer from poor front end performance. (OK, well, a lot of things are worse &#8212; but it&#8217;s still frustrating!). The Firebug <span style="font-style: italic;">Net</span> profiler can help get to the source of that slowness.</p>
<p>Although it is far from robust, the <span style="font-style: italic;">Net </span>tab offers semi-reliable metrics on the download speed of all assets including the HTML document, CSS, JavaScript, images and any other linked files.</p>
<p>You can see which files are being downloaded concurrently and which are blocking (hint: it&#8217;s the JavaScript), and how many connections are being opened with a given domain.</p>
<p>For more extensive page profiling, be sure to check out <a href="http://developer.yahoo.com/yslow/"><span style="font-style: italic;">YSlow</span>!</a>, a plugin for Firebug  (I guess that makes it an extension-of-an-extension) developed by Yahoo.</p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.thetruetribe.com%2F2008%2F03%2Ffirebug-tutorial-getting-started%2F&amp;linkname=Firebug%20Tutorial%3A%20Getting%20Started"><img src="http://www.thetruetribe.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://www.thetruetribe.com/2008/03/firebug-tutorial-getting-started/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
