SlideShare uma empresa Scribd logo
1 de 21
Javascript Debugging
Agenda
•   Browser-Specific Tools
     o IE 6/7: MS Script Debugger, MS Script Editor, MS Visual Studio (also IE Dev Toolbar)
     o IE 8: Developer Tools
     o Safari: Web Inspector
     o Chrome: Dev Tools (JS Console, DOM Inspector)
     o FireFox: Firebug
•   General Tools
     o YUI Logger
     o Alerts, prompts, and console.log()
     o JSLint
•   Common Pitfalls
     o Suppressed errors
     o Trailing commas in IE
     o Conflicting XHR requests
•   Using a Debugger
     o Step In/Over/Out
     o Breakpoints (also Conditional Breakpoints and Console)
     o Watch expressions
     o NET panel for XHR requests
     o Call stack
Browser-specific Tools

From "worst" to "best" (IMHO)....

• IE6/7: MS Script Debugger/MS Script Editor/MS Visual
  Studio (also IE Dev Toolbar)
• IE8: Developer Tools (can run in IE7 mode)
• Safari: Web Inspector
• Chrome: Developer Tools + JS Console
• Firefox: Firebug
Internet Explorer 6 & 7

• Need to enable JS errors in browser settings ("Display a
  notification for every script error")
• MS Script Debugger/MS Script Editor/MS Visual Studio
   o Separate downloads
   o Separate app, runs alongside the browser
   o Complicated to set-up
   o Clunky & difficult to use


• IE Dev Toolbar (But no JS debugger!)
• No easy way to disable JS on the fly
Internet Explorer 6 & 7
Internet Explorer 6 & 7
IE8: Developer Tools

•   Built into browser
•   Enable via Tools » Developer Tools
•   DOM inspector & JS debugger/profiler
•   IE7 mode
•   Can disable JS on the fly
IE8: Developer Tools
Safari: Web Inspector

•   Built into browser
•   Enable via Preferences » Advanced » Show Develop Menu
•   DOM Inspector + JS Debugger + Network + Console
•   Can disable JS under Develop menu
Safari: Web Inspector
Chrome: Developer Tools

•   Built into browser
•   Enable via View » Developer » Developer Tools
•   DOM Inspector + Network + JS Debugger + Console
•   Latest versions can pretty-print code
•   Can't disable JS on the fly
Chrome: Developer Tools
Firefox: Firebug

•   Add-on browser extension (http://getfirebug.com)
•   Enable via Tools » Firebug » Open Firebug
•   Console + Profiler + Debugger + Network
•   Can disable JS on the fly
•   Currently the "best" option (Chrome Dev Tools are a close
    second)
Firefox: Firebug
Firefox: Firebug
General Tools

• alert("something"); creates a popup dialog in most
  browsers
• console.log("something"); writes to browser's JS
  console if available
• JSLint (http://www.jslint.com/)
• YUI Logger (http://developer.yahoo.com/yui/logger/)
• Firebug Lite (http://getfirebug.com/firebuglite)
Common Gotchas
• Suppressed errors
    window.onerror = function() {};
    eval(/* some code here */);

• Compressed/Minified code
    function a(){var d,b=1,c=2;d=b+c;}

• Trailing commas in IE
     var config = {
            foo: "a thing",
            bar: "another thing",
            baz: "yet another thing",
     }

• Conflicting AJAX requests -- use Network panel to inspect
Using a Debugger

–   Where is the broken code? (Browser errors or console)
–   Set breakpoint(s)
–   Re-run script (reload or click)
–   Step through code (in/over/out) & inspect variables
–   Test using console
–   Fix code & repeat
Firefox: Firebug
Now You Try It!

1. Add Firebug to Firefox

– Browse to http://scream-
  ld.linkedin.biz/~jgourgou/jsdebug/excercises/

– Find the bugs in the examples!
Further Reading

• http://www.alistapart.com/articles/advanced-debugging-with-jav
  /
• http://blogs.msdn.com/b/ie/archive/2004/10/26/247912.aspx
• http://www.jonathanboutelle.com/how-to-debug-javascript-in-in
  explorer
• https://developer.mozilla.org/en/Debugging_JavaScript
• http://www.webmonkey.com/2010/02/javascript_debugging_for

Mais conteúdo relacionado

Semelhante a Javascript Debugging

Inspect The Uninspected
Inspect The UninspectedInspect The Uninspected
Inspect The Uninspectedcgack
 
Cape Cod Web Technology Meetup - 3
Cape Cod Web Technology Meetup - 3Cape Cod Web Technology Meetup - 3
Cape Cod Web Technology Meetup - 3Asher Martin
 
jQueryTO: State of jQuery March 2013
jQueryTO: State of jQuery March 2013jQueryTO: State of jQuery March 2013
jQueryTO: State of jQuery March 2013dmethvin
 
Web development-work space
Web development-work spaceWeb development-work space
Web development-work spacechawlan
 
Web dev tools review
Web dev tools reviewWeb dev tools review
Web dev tools reviewChanghyun Lee
 
JavaScript debugging diagnostic web tools and firefox
JavaScript debugging diagnostic web tools and firefoxJavaScript debugging diagnostic web tools and firefox
JavaScript debugging diagnostic web tools and firefoxGennady Feldman
 
Debugging webOS applications
Debugging webOS applicationsDebugging webOS applications
Debugging webOS applicationsfpatton
 
[ENG] Hacker halted 2012 - Zombie browsers, spiced with rootkit extensions
[ENG] Hacker halted 2012 - Zombie browsers, spiced with rootkit extensions[ENG] Hacker halted 2012 - Zombie browsers, spiced with rootkit extensions
[ENG] Hacker halted 2012 - Zombie browsers, spiced with rootkit extensionsZoltan Balazs
 
Marco Liberati - Write once, debug everywhere
Marco Liberati - Write once, debug everywhereMarco Liberati - Write once, debug everywhere
Marco Liberati - Write once, debug everywhereCodemotion
 
External JavaScript Widget Development Best Practices
External JavaScript Widget Development Best PracticesExternal JavaScript Widget Development Best Practices
External JavaScript Widget Development Best PracticesVolkan Özçelik
 
Java scriptwidgetdevelopmentjstanbul2012
Java scriptwidgetdevelopmentjstanbul2012Java scriptwidgetdevelopmentjstanbul2012
Java scriptwidgetdevelopmentjstanbul2012Volkan Özçelik
 
External JavaScript Widget Development Best Practices (updated) (v.1.1)
External JavaScript Widget Development Best Practices (updated) (v.1.1) External JavaScript Widget Development Best Practices (updated) (v.1.1)
External JavaScript Widget Development Best Practices (updated) (v.1.1) Volkan Özçelik
 
State of jQuery - AspDotNetStorefront Conference
State of jQuery - AspDotNetStorefront ConferenceState of jQuery - AspDotNetStorefront Conference
State of jQuery - AspDotNetStorefront Conferencedmethvin
 
.NET Debugging Tips and Techniques
.NET Debugging Tips and Techniques.NET Debugging Tips and Techniques
.NET Debugging Tips and TechniquesBala Subra
 
.Net Debugging Techniques
.Net Debugging Techniques.Net Debugging Techniques
.Net Debugging TechniquesBala Subra
 
Phonegap Development & Debugging
Phonegap Development & DebuggingPhonegap Development & Debugging
Phonegap Development & DebuggingIvano Malavolta
 

Semelhante a Javascript Debugging (20)

Inspect The Uninspected
Inspect The UninspectedInspect The Uninspected
Inspect The Uninspected
 
Cape Cod Web Technology Meetup - 3
Cape Cod Web Technology Meetup - 3Cape Cod Web Technology Meetup - 3
Cape Cod Web Technology Meetup - 3
 
orcreatehappyusers
orcreatehappyusersorcreatehappyusers
orcreatehappyusers
 
orcreatehappyusers
orcreatehappyusersorcreatehappyusers
orcreatehappyusers
 
jQueryTO: State of jQuery March 2013
jQueryTO: State of jQuery March 2013jQueryTO: State of jQuery March 2013
jQueryTO: State of jQuery March 2013
 
Web development-work space
Web development-work spaceWeb development-work space
Web development-work space
 
Web dev tools review
Web dev tools reviewWeb dev tools review
Web dev tools review
 
JavaScript debugging diagnostic web tools and firefox
JavaScript debugging diagnostic web tools and firefoxJavaScript debugging diagnostic web tools and firefox
JavaScript debugging diagnostic web tools and firefox
 
Debugging webOS applications
Debugging webOS applicationsDebugging webOS applications
Debugging webOS applications
 
[ENG] Hacker halted 2012 - Zombie browsers, spiced with rootkit extensions
[ENG] Hacker halted 2012 - Zombie browsers, spiced with rootkit extensions[ENG] Hacker halted 2012 - Zombie browsers, spiced with rootkit extensions
[ENG] Hacker halted 2012 - Zombie browsers, spiced with rootkit extensions
 
Marco Liberati - Write once, debug everywhere
Marco Liberati - Write once, debug everywhereMarco Liberati - Write once, debug everywhere
Marco Liberati - Write once, debug everywhere
 
External JavaScript Widget Development Best Practices
External JavaScript Widget Development Best PracticesExternal JavaScript Widget Development Best Practices
External JavaScript Widget Development Best Practices
 
Java scriptwidgetdevelopmentjstanbul2012
Java scriptwidgetdevelopmentjstanbul2012Java scriptwidgetdevelopmentjstanbul2012
Java scriptwidgetdevelopmentjstanbul2012
 
External JavaScript Widget Development Best Practices (updated) (v.1.1)
External JavaScript Widget Development Best Practices (updated) (v.1.1) External JavaScript Widget Development Best Practices (updated) (v.1.1)
External JavaScript Widget Development Best Practices (updated) (v.1.1)
 
State of jQuery - AspDotNetStorefront Conference
State of jQuery - AspDotNetStorefront ConferenceState of jQuery - AspDotNetStorefront Conference
State of jQuery - AspDotNetStorefront Conference
 
Browser Developer Tools
Browser Developer ToolsBrowser Developer Tools
Browser Developer Tools
 
How browser work
How browser workHow browser work
How browser work
 
.NET Debugging Tips and Techniques
.NET Debugging Tips and Techniques.NET Debugging Tips and Techniques
.NET Debugging Tips and Techniques
 
.Net Debugging Techniques
.Net Debugging Techniques.Net Debugging Techniques
.Net Debugging Techniques
 
Phonegap Development & Debugging
Phonegap Development & DebuggingPhonegap Development & Debugging
Phonegap Development & Debugging
 

Último

08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 

Último (20)

08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 

Javascript Debugging

  • 2. Agenda • Browser-Specific Tools o IE 6/7: MS Script Debugger, MS Script Editor, MS Visual Studio (also IE Dev Toolbar) o IE 8: Developer Tools o Safari: Web Inspector o Chrome: Dev Tools (JS Console, DOM Inspector) o FireFox: Firebug • General Tools o YUI Logger o Alerts, prompts, and console.log() o JSLint • Common Pitfalls o Suppressed errors o Trailing commas in IE o Conflicting XHR requests • Using a Debugger o Step In/Over/Out o Breakpoints (also Conditional Breakpoints and Console) o Watch expressions o NET panel for XHR requests o Call stack
  • 3. Browser-specific Tools From "worst" to "best" (IMHO).... • IE6/7: MS Script Debugger/MS Script Editor/MS Visual Studio (also IE Dev Toolbar) • IE8: Developer Tools (can run in IE7 mode) • Safari: Web Inspector • Chrome: Developer Tools + JS Console • Firefox: Firebug
  • 4. Internet Explorer 6 & 7 • Need to enable JS errors in browser settings ("Display a notification for every script error") • MS Script Debugger/MS Script Editor/MS Visual Studio o Separate downloads o Separate app, runs alongside the browser o Complicated to set-up o Clunky & difficult to use • IE Dev Toolbar (But no JS debugger!) • No easy way to disable JS on the fly
  • 7. IE8: Developer Tools • Built into browser • Enable via Tools » Developer Tools • DOM inspector & JS debugger/profiler • IE7 mode • Can disable JS on the fly
  • 9. Safari: Web Inspector • Built into browser • Enable via Preferences » Advanced » Show Develop Menu • DOM Inspector + JS Debugger + Network + Console • Can disable JS under Develop menu
  • 11. Chrome: Developer Tools • Built into browser • Enable via View » Developer » Developer Tools • DOM Inspector + Network + JS Debugger + Console • Latest versions can pretty-print code • Can't disable JS on the fly
  • 13. Firefox: Firebug • Add-on browser extension (http://getfirebug.com) • Enable via Tools » Firebug » Open Firebug • Console + Profiler + Debugger + Network • Can disable JS on the fly • Currently the "best" option (Chrome Dev Tools are a close second)
  • 16. General Tools • alert("something"); creates a popup dialog in most browsers • console.log("something"); writes to browser's JS console if available • JSLint (http://www.jslint.com/) • YUI Logger (http://developer.yahoo.com/yui/logger/) • Firebug Lite (http://getfirebug.com/firebuglite)
  • 17. Common Gotchas • Suppressed errors window.onerror = function() {}; eval(/* some code here */); • Compressed/Minified code function a(){var d,b=1,c=2;d=b+c;} • Trailing commas in IE var config = { foo: "a thing", bar: "another thing", baz: "yet another thing", } • Conflicting AJAX requests -- use Network panel to inspect
  • 18. Using a Debugger – Where is the broken code? (Browser errors or console) – Set breakpoint(s) – Re-run script (reload or click) – Step through code (in/over/out) & inspect variables – Test using console – Fix code & repeat
  • 20. Now You Try It! 1. Add Firebug to Firefox – Browse to http://scream- ld.linkedin.biz/~jgourgou/jsdebug/excercises/ – Find the bugs in the examples!
  • 21. Further Reading • http://www.alistapart.com/articles/advanced-debugging-with-jav / • http://blogs.msdn.com/b/ie/archive/2004/10/26/247912.aspx • http://www.jonathanboutelle.com/how-to-debug-javascript-in-in explorer • https://developer.mozilla.org/en/Debugging_JavaScript • http://www.webmonkey.com/2010/02/javascript_debugging_for