Professional Documents
Culture Documents
com
CONTENTS INCLUDE:
n
About Firebug Getting Started with
Firebug 1.5
n
Installation
n
Inspecting Page Elements
n
JavaScript Profiling
n
Keyboard and Mouse Shortcuts
n
Console API Reference and more...
By Chandan Luthra & Deepak Mittal
• Move your cursor on the page component/section that
ABOUT FIREBUG you want to inspect.
• Click on the page component/section to investigate it.
Firebug is a free and open-source tool, available as a Mozilla
Firefox extension, which allows debugging, editing and There is another easy and fast way to inspect an element. Just
monitoring of any website’s CSS, HTML, DOM and JavaScript. right click on the page component/section and select “Inspect
It allows performance analysis of a website and has a Element” from the context menu. You can also directly select
JavaScript console for logging errors and watching values. a DOM node under the HTML tab to view its style, layout, &
Firebug has many other tools to enhance the productivity DOM attributes.
of today’s web developer. Firebug provides all the tools
that a web-developer needs to analyze, debug and monitor JAVASCRIPT PROFILING
JavaScript, CSS, HTML and Ajax. Firebug includes a debugger,
error console, command line, and a variety of useful inspectors. Type the following code in an HTML file, save it and open it up
with Firebug enabled Firefox (if Firebug is not enabled then
Please note that though Firebug allows you to make press F12 key to activate it):
changes to the source code of your web page, but
<html>
the changes are done to the copy of the HTML code
www.dzone.com
This is the first and main step for investigating an HTML element.
Call: Shows the count of how many times a particular function Click on the “Click Me!” button to start the execution. You will
has been invoked. (3 times for loop() function in our case.) notice that JS execution is paused at the breakpoint that you
set.
Percent: Shows the time consuming of each function in
percentage. You can now step debug the JavaScript by pressing one of
these buttons (Continue, Step Over, Step Into and Step Out)
Own Time: Shows the duration of own script in a particular under the “Script” tab.
function. For example foo() function has none of its own code.
Instead, it is just calling other functions. So, its own execution
time will be ~0ms. If you want to see some values for that
column, add some looping in this function. • Continue (F8): Allows you to resume the script execution
once it has been stopped via another breakpoint.
Time: Shows the duration of execution from start point of a
function to the end point of a function. For example foo() has • Step Over (F10): Allows you to step over the function call.
no code. So, its own execution time is approx ~0ms, but we • Step Into (F11): Allows you to step into the body of the
call other functions in that function. So, the total execution another function.
time of other functions is 4.491ms. So, it shows 4.54ms in that
• Step Out: Allows you to resume the script execution and
column which is equal to own time taken by 3 loop() function +
will stop at next breakpoint.
own time of foo().
Avg: Shows the average execution time of a particular function. TWEAK CSS ON THE FLY
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 Through Firebug, you can add, remove and change the CSS
the differences. The formula for calculating the average is: properties of inspected elements. This is a most useful feature
Avg = Own time / Call of Firebug through which one can fix the UI issues rapidly and
easily. You can watch the live demo of the changes that you are
Min and Max columns: Shows the minimum execution time of
making in the CSS tab. If you want to add the ‘color’ property
a particular function. In our example, we call loop() for 3 times.
of an inspected element:
When we passed 1000 as a parameter, it probably took only
a few millisecond (let’s say 0.045ms.) and when, we passed • ‘Double-click’ on the ‘Style’ panel of HTML tab. A little
100000 to that function, it took much longer than first time (let’s text editor will appear and type ‘color’ followed by a
say 4.036ms). So, in that case, 0.045ms will be shown in Min ‘TAB’ key.
column and 4.036ms will be shown in Max column.
• Now the tiny text editor moves to the right side of the
File: Shows the file name of file with line number where the ‘color’ property asking you to enter the value (color code)
function is located for the property. Provide a value to it and press enter to
see the magic.
JAVASCRIPT DEBUGGING
Firebug allows you to insert break points and step debug the
JS code.
<html>
<head><title>Javascript Debugging</title>
<script>
function populateDiv(){
var divElement = document.
getElementById(‘messageLabel’);
divElement.innerHTML = “Lorem ipsum dollor”;
}
</script></head>
<body>
<div id=”messageLabel”></div>
<input type=”button” value=”Click Me!”
onclick=”populateDiv();” />
</body></html>
Hot To verify that you have inserted a break point, you can see
the list of breakpoints in the “Breakpoints” panel on the To disable a CSS rule, move the mouse pointer near to the CSS
Tip right side of “Script” tab. rule. Click on the ‘do-not’ icon that appears on the left side
of the rule.
To change a specific CSS rule, simply click on the rule, a text or XML. This is very useful while debugging any AJAX code,
editor will appear asking you for the new property or value. and it’s also quite fun to analyse how other web pages use AJAX.
Color Description THE cd() METHOD
Green Time for DNS Lookup
By default all the expressions and functions that you execute
Light Green Time to connect to the server in the command line are relative to the top level window of
Light Brown Time for which the request had to wait in the queue the page. For example, you cannot invoke any function from
Firebug’s command line if that function is defined in an iFrame
Purple Time waiting for a response from the server
within a page. Firebug provides a solution for such situation.
Dark Grey Request was sent to server, request served by the server The cd() method allows you to change the context of the
and not from browser cache window from main window to the iFrame.
Light Grey Request was sent to the server, “304 Not Modified” On the Firebug command use the following syntax against a
received from server, response loaded from the browser page that has an iFrame
cache
Syntax:
Global Shortcuts
Task / Operation Shortcut
Open Firebug Panel F12
Close Firebug Panel F12
Open Firebug in Window Ctrl+F12
Each XMLHttpRequest will be automatically logged to the
Switch to Previous Tab Ctrl+`
console, where we you can inspect its response as text, JSON,
#82
CONTENTS INCLUDE:
■
■
About Cloud Computing
Usage Scenarios Getting Started with
Aldon Cloud#64Computing
■
Underlying Concepts
Cost
by...
■
Upcoming Refcardz
youTechnologies ®
■
Data
t toTier
brough Comply.
borate.
Platform Management and more...
■
Chan
ge. Colla By Daniel Rubio
tion:
dz. com
tegra ternvasll
ABOUT CLOUD COMPUTING one time events. TEN TS
INC ■
HTML LUD E:
us Ind Anti-PPaat
Basics
Automated growthHTM
ref car
nuorn
■
Valid
ation one time events, cloud ML
connected to what is now deemed the ‘cloud’. Having the capability to support
Apache Ant
Usef
Du
ti
■
ul M.
computing platforms alsoulfacilitate
#84
Open the gradual growth curves
n an
Page Source
o
■
s
Vis it
C
faced by web applications. Tools
Core
By Key ■
Elem
Patte
has changed substantially in recent years, especially with Structur
E: al Elem ents
INC LUD gration the entrance of service providers like Amazon, Google and Large scale growth scenarios involvingents
specialized
NTS and mor equipment
rdz !
HTML
CO NTE Microsoft. es e... away by
(e.g. load balancers and clusters) are all but abstracted
Continu at Every e chang
m
About ns to isolat
relying on a cloud computing platform’s technology.
Software i-patter
space
Hadoop
rdz .co
■
n
Re fca
e Work
Build
riptio
and Ant
Desc
These companies have a Privat
are in long deployed
trol repos
itory
webmana applications
ge HTM
L BAS
■
Build
re
Buil Repo
This Refcard active
will introduce are within
to you to cloud riente computing, with an
d units
RATION etc. Some platforms ram support large grapRDBMS deployments.
■
The src
dy Ha
softw
e ine loping and Java s written in hical on of
INTEG attribute
task-o it all
softwar emphasis onDeve es by
Mainl these
ines providers, so youComm can better understand
also rece JavaScri user interfac web develop and the rris
Vis it
Spring Security
codel chang desc
INUOU ding Task Level as the
e code
w ww.dzone.com
Label
Build
manu
al
d tool
depe deplo t need but as if
eve , a ) stalle the same nmen for stan overlap uen
(i.e. , inef Build t, use target enviro Amazon EC2: Industry standard it has
software and uagvirtualization ine. HTM , so <a>< tly are) nest
with terns problem ce pre-in whether dards
ated b></
ory. ns (i.e. Autom Redu ymen
has bec become e with a> is
via pat ticular d deploEAR) in each very little L
Subversion
reposit -patter s that Pay only cieswhat you consume
tagge or Amazon’s cloud
the curr you cho platform
computing isome
heavily based moron fine. b></ ed insid
lained ) and anti the par solution duce nden For each (e.g. WAR es t
ent stan ose to writ more e imp a></ e
not lega each othe
x” b> is
be exp text to “fi are al Depeapplication deployment
Web ge until t a
librarifew years agonmen
t enviro was similar that will softwaredard
industry standard and virtualization app
e HTM technology.
orta nt,
tterns to pro Minim packa nden
Mo re
CI can ticular con used can rity all depe all targe
s will L or XHT arent. Reg the HTM l, but r. Tags
etimes Anti-pa they
tend
es, but to most phone services:
y Integ alizeplans with le that
late fialloted resources, ts with an and XHT simplify all help ML, und ardless
L VS
XHTM <a><
in a par hes som
Centr
end,
Binar
pro cess. the practic enti ng incurred costgeme
nt
whether e a single
such
temp
resources on
were consumed
t enviro
nmen
orthenot. Virtualization MLaare your
othe
you prov
erst of L
b></
in muchallows physical piece of hardware to
ide be HTM
rily bad
Mana based
approac ed with the cial, but, implem anding
Creat targe es to actually r web
nden
cy rties are nt
of the a solid L has
into differe coding.resources
necessa pared to
chang
efi Depe prope itting utilized by multiple operating
function systems.simplerThis allows foundati job adm been arou
associat to be ben
er
Ge t
te builds commo
are not Fortuna
late Verifi e comm than on
n com Cloud computing asRun it’sremo
known etoday has changed this.
befor alitytohas irably, nd for
They they
etc.
Temp Build (e.g. bandwidth, n memory, CPU) be allocated exclusively to tely exp that som
lts whe
ually,
appear effects. Privat y, contin Every elem mov used
to be, HTML
ecte job e time
ed resu The various resourcesPerfo rm a
consumed by webperio applications
dicall (e.g. nt team
pag
individual operating entsinstances. ed to CSS
system Brow d. Earl
y HTM has expand . Whi
gration
opme because
adverse unintend d Builds sitory Build r to devel common e (HTML . ser ed far le it has don
ous Inte web dev manufacture L had very
Stage Repo
e bandwidth, memory, CPU) areIntegtallied
ration on a per-unit CI serve basis or XHT
produc tinu e Build rm an from
extensio .) All are more e its
e.com
DZone, Inc.
Cloud Computing
the
s on
expand
ISBN-13: 978-1-934238-75-2
140 Preston Executive Dr. ISBN-10: 1-934238-75-9
Suite 100
50795
Cary, NC 27513