Successfully reported this slideshow.

Javascript Stacktrace Ignite

2,276 views

Published on

Bite-size talk on the Javascript Stacktrace project

  • Be the first to comment

  • Be the first to like this

Javascript Stacktrace Ignite

  1. 1. The JavaScript Stacktrace Project Making cross-browser compatibility suck a little less © 2010 Eric Wendelin
  2. 2. Let me say this upfront... You care about this project* * Probably
  3. 3. D’oh!
  4. 4. What would you do?
  5. 5. IE Developer Tools Yay... won’t this be fun?
  6. 6. What if you could get...
  7. 7. Javascript Stacktrace Micro-library for getting function stack traces in all* web browsers * NOTE: Must actually support Javascript
  8. 8. In a nutshell... printStackTrace() return [ ‘calledFromFoo(my.js:32)’, ‘foo(my.js:23)’, ‘callsFoo(my.js:14)’, ‘{anonymous}(other.js:1)’, ... ]
  9. 9. Licensed to the public domain ~1.8k minified and gzipped
  10. 10. Works in
  11. 11. How it works function foo() { //calling function! arguments.callee.caller //passed parameters! arguments.callee.caller.arguments }
  12. 12. Bonus: Error objects try { (0)(); // produce an error } catch (error) { error.stack; // Firefox, Chrome error.stacktrace || error.message; // Opera }
  13. 13. Step 1: <script type=”text/javascript” src=”stacktrace.js”></script> Step 2: var trace = printStackTrace(); Step 3: showError(trace.join(‘n’));
  14. 14. • Now at 5 contributors • 130+ watchers on GitHub
  15. 15. Coming soon... • IE9 support • Function instrumenting to always print a stacktrace when called (done!) • Real-time traces (maybe! - not as easy as you think ;)
  16. 16. Secrets to open-source success
  17. 17. Good idea > good skill
  18. 18. Unit tests help others contribute
  19. 19. Just release it
  20. 20. su.pr/AH9ShK [ http://github.com/emwendelin/javascript-stacktrace ] Blog: eriwen.com Twitter: @eriwen Email: emwendelin@gmail.com © 2010 Eric Wendelin

×