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:

  1. switch html panel , there events side panel.
  2. scroll down section saying other listeners window
  3. 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.

  4. reload page.

here's screenshot of menu: setting breakpoint @ 'load' event

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:

  1. inside script panel select first script called inline script location menu (the third toolbar button left).
  2. search first javascript line, or, if there no inline javascript, select script within first <script> element script location menu.
  3. set breakpoint @ first line of script.
  4. reload page.

Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -