Firebug 1.5: Editing, Debugging, and Monitoring Web Pages - Luthra Chandan - E-Book

Firebug 1.5: Editing, Debugging, and Monitoring Web Pages E-Book

Luthra Chandan

0,0
19,35 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.

Mehr erfahren.
Beschreibung

In Detail

With the advent of RIA (Rich Internet Applications), most web pages are driven by a combination of JavaScript, AJAX, CSS, and so on. Web developers and designers find it hard to debug and fix the issues that crop up on the client side. Firebug is a wonderful toolkit to have in your arsenal for handling all such issues. This book covers all of Firebug's features and will help you utilize its capabilities with maximum efficiency. AJAX development and debugging is not one of the easiest tasks; this book explains step-by-step, how to develop and debug AJAX components in your web page in a very easy way, thereby increasing your productivity. Topics like performance tuning of the web page are covered in detail.

This book discusses how to become more efficient in various aspects of web development by using Firebug. It is a very easy-to-understand, step-by-step guide that explains all the features of Firebug with concise and simple examples. With this book in hand, you will be able to deal with the painful areas of web development like JavaScript and AJAX debugging using Firebug.

The book takes you from the basics of Web Development like editing HTML and CSS on the fly to advanced features like AJAX, JSON, Monitoring, and Performance Tuning of web pages. It assumes that you have some very basic knowledge of HTML and JavaScript. For those of you with a sound knowledge of these technologies, this book can help you increase your productivity by using Firebug effectively, taking full advantage of its rich and powerful features and the console API. Towards the end, the book explains how to create your own powerful extensions for the Firebug community.

This practical guide will equip you with the skills to edit, debug, and monitor web pages using Firebug

Approach

A step-by-step description of each key feature is provided with the help of simple, easy-to-understand examples. There are plenty of useful screenshots in each chapter. Every chapter contains information as well as tips and tricks to draw your attention towards some useful information or reference. Each aspect of web development like CSS or JavaScript is handled independently so that you can refer to those modules in which you are interested.

Who this book is for

This book is written for frontend web developers building software and pages using HTML, CSS, JavaScript, and AJAX, who want to learn Firebug for the reasons outlined above. The book assumes that readers have a very basic knowledge of HTML, JavaScript, and CSS. The examples in the book can be understood by someone who has just been introduced to web development.

Sie lesen das E-Book in den Legimi-Apps auf:

Android
iOS
von Legimi
zertifizierten E-Readern

Seitenzahl: 180

Veröffentlichungsjahr: 2010

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



Table of Contents

Firebug 1.5: Editing, Debugging, and Monitoring Web Pages
Credits
About the Authors
About the Reviewers
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code for the book
Errata
Piracy
Questions
1. Getting Started with Firebug
What is Firebug?
The history of Firebug
The need for Firebug
Firebug capabilities
Installing Firebug on different browsers
Installing Firebug on Firefox
Installing Firebug on non-Firefox browsers
Opening and closing Firebug
Firebug modes
Dock view
Window mode
Summary
2. Firebug Window Overview
Console tab
Command line JavaScript
Errors and warnings
Status bar error indicator
Errors can be descriptive and informative
Executing JavaScript commands
HTML tab
The hierarchy of DOM nodes (the HTML source panel)
Options for HTML source panel
Editing HTML on the fly
Editing an existing attribute of HTML element
Editing an HTML element
Logging events
CSS tab
CSS inspector
List of CSS files
Modifying CSS
Script tab
DOM tab
Net tab
Summary
3. Inspecting and Editing HTML
Viewing source live
Seeing changes highlighted
Modifying the source on the fly
How to modify the value of an HTML attribute
How to add a new attribute to an existing HTML element
How to delete an HTML element
How to modify the source for an HTML element
Inspecting page components, editing, and reloading
Searching within an HTML document
Finding an HTML element on the page
Copying HTML source for an HTML element
Setting breakpoints on HTML element
Summary
4. CSS Development
Inspecting cascading rules
Preview colors and images
Tweaking CSS on the fly
Enabling and disabling specific CSS rules
Inspecting our stylesheet
Modifying CSS from Firebug's UI
Inspecting and tweaking the box model
Searching under the CSS tab
Summary
5. JavaScript Development
The command line API
$(id)
$ $$(selector)
$x(xpath)
dir(object)
dirxml(node)
clear()
inspect(object[, tabName])
keys(object)
values(object)
debug(fn) and undebug(fn)
monitor(functionName) and unmonitor(functionName)
monitorEvents(object[, types])
unmonitorEvents(object[, types])
profile([title]) and profileEnd()
Columns and description of the profiler
The console API
console.log(object[, object, ...])
console.debug(object[, object, ...])
console.info(object[, object, ...])
console.warn(object[, object, ...])
console.error(object[, object, ...])
console.assert(expression[, object, ...])
console.dir(object)
console.dirxml(node)
console.trace()
console.group(object[, object, ...])
console.groupCollapsed(object[, object, ...])
console.groupEnd()
console.time(name)
console.timeEnd(name)
console.profile([title])
console.profileEnd()
console.count([title])
JavaScript debugging
Steps to debug JavaScript code with Firebug
Conditional breakpoints
Summary
6. Knowing Your DOM
Inspecting DOM
Filtering properties, functions, and constants
Modifying DOM on the fly
Auto-complete
Losing the starting element
Adding/removing the DOM elements' attributes
Removing attributes
Adding attributes
JavaScript code navigation
Summary
7. Performance Tuning Our Web Application
Network monitoring
Description of information in the Net panel
Load-time bar color significance
Browser queue wait time
Breaking down various requests by type
Examining HTTP headers
Analyzing the browser cache
XMLHttpRequest monitoring
How to find out the download speed for a resource
Firebug extensions for analyzing performance
Summary
8. AJAX Development
Tracking XmlHttpRequest
Request/response headers and parameters
GET/POST request
Viewing live modifications on DOM
Debugging AJAX calls using properties of a console object
console.debug(object[, object, ...])
console.assert(expression[, object, ...])
console.dir(object)
Summary
9. Tips and Tricks for Firebug
Magical cd()
The hierarchical console
Configuring Firebug to our taste
Summary
10. Necessary Firebug Extensions
YSlow
Firecookie
Pixel Perfect
Pixel Perfect options menu
Firefinder
FireQuery
CodeBurner
SenSEO
Page Speed
Summary
11. Extending Firebug
Setting up an extension development environment
Setting up the development profile
Development preferences
Getting started with a small "Hello World!" extension of Firebug
The chrome.manifest file
The install.rdf file
The helloWorldOverlay.xul file
The helloWorld.js file
Packaging and installation
Taking "Hello World!" to the next level
The "prefs.js" file
The "helloWorld.js" file revisited
Summary
A. A Quick Overview of Firebug's Features and Options
Keyboard and mouse shortcuts reference
Global shortcuts
HTML tab shortcuts
HTML editor shortcuts
HTML inspect mode shortcuts
Script tab shortcuts
DOM tab shortcuts
DOM and watch editor shortcuts
CSS tab shortcuts
CSS editor tab shortcuts
Layout tab shortcuts
Layout editor shortcuts
Command line (small) shortcuts
Command line (large) shortcuts
Console API reference
Command line API reference
Firebug online resources
Features expected in future releases of Firebug
Firebug 1.6
Some improvements in this version
Scrolling panel tab bar
FBTest support for Firebug extensions
Locales as extensions
Extension points for panel buttons and main menu options
Breakpoint column for the HTML panel
Break on next CSS change and CSS breakpoints
Options for the break on next feature (mainly a UI-related issue)
Net panel improvements
Script panel improvements
JavaScript function support
Firebug 1.7
Separate modules and panels
Issue: File names versus folder names
Components replaced by SharedObjects
Issue: SharedObject API
Recode TabWatcher/DOMWindowWatcher
Sandboxed extension loading
Memory panel
Index

Firebug 1.5: Editing, Debugging, and Monitoring Web Pages

Deepak Mittal

Chandan Luthra

Firebug 1.5: Editing, Debugging, and Monitoring Web Pages

Copyright © 2010 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the authors, Packt Publishing, nor its dealers or distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

First published: April 2010

Production Reference: 1300310

Published by Packt Publishing Ltd.

32 Lincoln Road

Olton

Birmingham, B27 6PA, UK.

ISBN 978-1-847194-96-1

www.packtpub.com

Cover Image by Filippo Sarti (<[email protected]>)

Credits

Authors

Chandan Luthra

Deepak Mittal

Reviewers

Balaji D Loganathan

Michael Ratcliffe

Michael Sync

Acquisition Editor

Dilip Venkatesh

Development Editor

Dilip Venkatesh

Technical Editors

Gaurav Datar

Rukhsana Khambatta

Copy Editor

Sanchari Mukherjee

Indexer

Hemangini Bari

Editorial Team Leader

Gagandeep Singh

Project Team Leader

Lata Basantani

Project Coordinator

Poorvi Nair

Proofreader

Aaron Nash

Graphics

Geetanjali G. Sawant

Production Coordinator

Adline Swetha Jesuthas

Cover Work

Adline Swetha Jesuthas

About the Authors

Chandan Luthra is a Software Development Engineer with IntelliGrape Software, New Delhi, India—a company specializing in Groovy/Grails development. He is an agile and pragmatic programmer and an active participant at local open source software events, where he evangelizes Groovy, Grails, Jquery, and Firebug. Chandan is a Linux and open source enthusiast. He also involves himself in writing blogs and is an active member on various tech-related mailing lists. He has developed web applications for various industries, including entertainment, finance, media and publishing, as well as others.

He loves to share his knowledge and good coding practices with other team members in order to hone their development skills. In his free time, he loves to contribute to open source technologies.

Chandan also loves to code in jQuery and Firebug, which makes development very easy for him. He is a very fond user of Firebug and has been using it since 2007.

I would like to thank my family for their love and support during my far-flung adventures into esoteric nonsense. Thanks also to all my cooperative colleagues at IntelliGrape for their feedback and suggestions. I would also like to thank Deepak Mittal for co-authoring and motivating me to write this book. Finally, I wish to thank Dilip Venkatesh (Acquisition Editor at Packt), Poorvi Nair (Project Coordinator at Packt), Micheal Sync (Reviewer), Micheal Ratcliffe (Reviewer), and Balaji Loganathan (Reviewer) for giving a perfect shape to this book. Special thanks to S. Vivek Krishna for his help on the Preface of the book.

Deepak Mittal is a software developer based in New Delhi, India, and he has been involved with software engineering and web programming in Java/JEE world since the late 1990s. Deepak is a Linux and open source enthusiast. He is an agile practitioner and speaks about open source, agile processes, and free software at various user group meetings and conferences. He has designed and built web applications for industries including pharmaceutical, travel, media, and publishing, as well as others. He loves to explore new technologies and has been an early-adopter of quite a few mainstream technologies of today's world.

In early 2008, he co-founded IntelliGrape Software, an agile web application development company focused on Groovy and Grails. At IntelliGrape, he has been occupied with building world class applications on Grails and also mentors and trains other team members.

Deepak is a veteran user of Firebug and has been using it since 2006.

I want to thank all my colleagues at IntelliGrape for their valuable feedback and suggestions, my family for putting up without me for weeks, and all the contributors of Firebug. My special thanks go to Dilip Venkatesh (Acquisition Editor at Packt), Poorvi Nair (Project Coordinator at Packt), Chandan Luthra (my co-author), and all the reviewers of the book.

About the Reviewers

Balaji D Loganathan has 10+ years of experience in the software field, is a CEO and Co-founder of Spritle Software—a software development company in Chennai, India. Balaji is an Agile Guru specializing in Agile Offshore, a Certified Scrum Master. Balaji has a Master's degree in IT from the RMIT, Australia and a Bachelors Degree in Engineering from the Annamalai University, India.

When Michael Ratcliffe was 9 years old he saw a movie called "Wargames". Like many kids his age he became very interested in computers. A few weeks later he was playing "Roland in the Caves" on a friend's Amstrad CPC 464 when the game crashed and the command prompt displayed "Illegal Operation." Believing that he had hacked something, he decided that he wanted to become a full time hacker and therefore became much more determined to learn how computers work and what can be done with them.

At 12 years of age, his parents bought him an Acorn Electron Microcomputer as a Christmas present. Within 6 months he had written his first game, Wargames, in BBC Basic. By the time he was 14, he was regularly writing programs in 6502 Assembly language and would regularly send pokes (infinite lives, invulnerability, and so on) to computer magazines to help people with their new games.

At 15 years of age, he started work in IT as a support engineer. His use of programming languages extended to Turbo C, C++, Pascal, Delphi, C#, VB, VBScript, VB.NET, HTML, JavaScript, ASP, PHP, Perl, and so on. Some years later he discovered that he was spending a large amount of time writing tools to help his colleagues with their work and decided that he should get the paper qualifications he would need. He started as a computer science major but, after receiving a ton of job offers in the field, he just dropped out of university and has been professional ever since.

Michael is currently working for Comartis AG, Switzerland on e-Learning software called i-qbox Human Performance Suite. He works daily with VB.NET, C#, and JavaScript but prefers JavaScript, claiming that its quirks just make the language more fun. As the "JavaScript Guy" he uses Firebug to get his work done properly. In 2008 he began logging Firebug issues and soon began spending lots of time fixing bugs to make his work easier. He worked for a time on Firebug Lite but spends most of his "spare time" now working on improving the Firebug Inspector, which he likes to think of as "Aardvark on Steroids."

He would like to thank his wife Sabine for her patience during the many hours spent performing technical reviews on this book.

Michael Sync has lately been associated with Memolife as a Solution Architect, responsible for building their products using Silverlight and other .Net technologies.

Prior to venturing into this, he was creating a niche in Web Application Development using ASP.NET, AJAX, JavaScript, and so on.

He had always believed in the concept of "Sharing Knowledge", which is the key to building his in-depth understanding of the technology. That's the main reason why he always tries to participate in public forums and local newsgroups for helping fellow technologists; benefits are also received, as learning is a two-way process.

Being a member of Microsoft WPF/Silverlight Insider team, he really enjoys playing with early drops of Silverlight and giving his feedback to the team.

Preface

Firebug is a free and open source tool, available as a Mozilla Firefox extension, which allows debugging, editing, and monitoring of any website's CSS, HTML, DOM, XHR, and JavaScript. Firebug 1.0 beta was released in December 2006. Firebug usage has grown very quickly since then. Approximately 1.3 million users have Firebug installed as of January 2009. It is a very popular tool among web developers to aid during web application development.

The book begins with the steps to install Firebug, followed by an overview of the Firebug window. We will get the basic idea of Firebug and movement across the different panels and tabs within Firebug.

From there, we will make our way towards more advanced usages of each tab, such as CSS development, JavaScript development, and DOM modification. This will aid us during client-side development and debugging of RIAs. We will also learn to use Firebug for performance tuning our application on the browser. We have also dealt with the tracking of XMLHttpRequest and XMLHttpResponse during AJAX development, which is also an integral part of RIAs. We will also learn a few tips and tricks for Firebug that will help us in configuring Firebug according to our taste and make it a pleasurable experience to work with it.

Once we are comfortable with the usage of Firebug, we will learn to install and use some popular Firebug extensions. This will be followed by a discussion on how to develop our own Firebug extension.

What this book covers

Chapter 1: Getting Started with Firebug gives a quick introduction to Firebug, its origin and history, who should use Firebug, and a glimpse of Firebug's main features, hoping that this will spark your interest in both Firebug and the rest of this book.

Chapter 2: Firebug Window Overview explains Firebug's tabs and what they are used for.

Chapter 3: Inspecting and Editing HTML provides an understanding of using Firebug to inspect, edit, search, and play with the HTML source of the document.

Chapter 4: CSS Development aims to help the reader to understand the useful tools and utilities provided by Firebug for CSS development.

Chapter 5: JavaScript Development explains command line API, console API of Firebug, and debugging JavaScript in detail.

Chapter 6: Knowing your DOM gives a small introduction to DOM as well as discussing how to modify/edit values of properties and constants of any DOM object using Firebug.

Chapter 7: Performance Tuning Our Web Application explains various ways to analyze the performance of your web application on the browser.

Chapter 8: AJAX Development discusses how to track XmlHttpRequest and XmlHttpResponse as well as debugging AJAX calls.

Chapter 9: Tips and Tricks for Firebug discusses a few tips and tricks that can be very useful while debugging and developing. We have explained how to play with the features that Firebug provides and what other things you should know about Firebug.

Chapter 10: Necessary Firebug Extensions explains some of the Firebug extensions, such as YSlow, FireCookie, Page Speed, and so on. They are useful for development and performance tuning.

Chapter 11: Extending Firebug discusses the steps to develop a Firebug extension. We have also discussed how to set up a development environment, along with file and directory structure for the extension.

Appendix, A Quick overview of Firebug's features and options gives a quick reference for various Firebug features and options.

What you need for this book

We will need Mozilla Firefox v 3.5 - 3.6 installed on our systems. We also need Firebug 1.4 - 1.5 installed on top of it. The latter is not a prerequisite as we will discuss how to install it during the course of the book.

Having an Internet connection would be an added advantage as the examples provided run on top of live websites. This will also help us in learning to install and use Firebug extensions.

Who this book is for

The target audience is front-end web developers who are building software and pages using HTML, CSS, JavaScript, and AJAX, and want to learn Firebug. The book assumes that the reader has a very basic knowledge of HTML, JavaScript, and CSS. The examples in the book can be understood by someone who has just been introduced to web development.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply drop an email to <[email protected]>, and mention the book title in the subject of your message.

If there is a book that you need and would like to see us publish, please send us a note in the SUGGEST A TITLE form on www.packtpub.com or email <[email protected]>.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code for the book

Visit http://www.packtpub.com/files/code/4961_Code.zip to directly download the example code.

Tip

The downloadable files contain instructions on how to use them.

Errata

Although we have taken every care to ensure the accuracy of our contents, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in text or code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration, and help us to improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the let us know link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata added to any list of existing errata. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at <[email protected]> with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at <[email protected]> if you are having a problem with any aspect of the book, and we will do our best to address it.

Chapter 1. Getting Started with Firebug

In this chapter, we will have a quick introduction to Firebug—its origin and history, who should use Firebug, and a glimpse of Firebug's main features. Hopefully this will spark your interest in both Firebug and the rest of this book. We will also look at how to install Firebug on several browsers and the different modes in which Firebug can be opened.

In this chapter, we will look at the following:

What is FirebugThe history of FirebugThe need for FirebugThe capabilities of FirebugInstalling Firebug on different browsersOpening and closing FirebugFirebug modes

What is Firebug?

Firebug is a free, open source tool that is available as a Mozilla Firefox extension, and allows debugging, editing, and monitoring of any website's CSS, HTML, DOM, and JavaScript. It also allows performance analysis of a website. Furthermore, it has a JavaScript console for logging errors and watching values. Firebug has many other tools to enhance the productivity of today's web developer.

Firebug integrates with Firefox to put a wealth of development tools at our fingertips while we browse a website. Firebug allows us to understand and analyze the complex interactions that take place between various elements of any web page when it is loaded by a browser.