debugging - Javascript: How to single-step site initialization? -
short background: i'm pretty new javascript , interested in customizing third-party websites needs — i.e. write scripts greasemonkey , like. sites bloated libraries jquery, bootstrap, etc. makes harder figure out how work.
when analyze new website , want know code gets executed, can use firebug create breakpoints or watchpoints , single-step through code. however, not work code runs while/when website first loads. how can single-step through part? i'm looking way set breakpoint point before first javascript code executed.
if there better tools firebug i'm open suggestions. please keep in mind not control website, changing site's code out of question.
if it's enough stop @ load event of page (normally code gets executed before event), can following:
- switch html panel , there events side panel.
- scroll down section saying other listeners window
right-click function under 'load' event (might 1 arrow besides it) , choose set breakpoint context menu.
note: there might 'domcontentloaded' event handler, called before 'load' event. so, if exists, set breakpoint @ function.
- reload page.
as mentioned above, code executed before 'load' event fired, libraries getting loaded or global variables being initialized. though far know, there no option in firebug (or other browser developer tools) stop script execution @ first executed javascript statement. it's still quite easy set breakpoint @ line. requires manual searching:
- inside script panel select first script called inline script location menu (the third toolbar button left).
- search first javascript line, or, if there no inline javascript, select script within first
<script>
element script location menu. - set breakpoint @ first line of script.
- reload page.
Comments
Post a Comment