Join the AMA (Ask Me Anything) with the Firefox leadership team to celebrate Firefox 20th anniversary and discuss Firefox’s future on Mozilla Connect. Mark your calendar on Thursday, November 14, 18:00 - 20:00 UTC!

Om de ûnderfining foar jo te ferbetterjen is tydlik de funksjonaliteit dan dizze website troch ûnderhâldswurk beheind. Wannear in artikel jo probleem net oplost en jo in fraach stelle wolle, kin ús stipemienskip jo helpe yn @FirefoxSupport op Twitter en /r/firefox op Reddit.

Sykje yn Support

Mij stipescams. Wy sille jo nea freegje in telefoannûmer te beljen, der in sms nei ta te stjoeren of persoanlike gegevens te dielen. Meld fertochte aktiviteit mei de opsje ‘Misbrûk melde’.

Mear ynfo

Dizze konversaasje is argivearre. Stel in nije fraach as jo help nedich hawwe.

How do I set a breakpoint on the first line of the first script in a page?

more options

Hello, everyone.

My question is the following:

I am using an inspector/debugger from the Firefox Development Tools. (Triggered by F12)

What I need is to set a breakpoint on the first line of the first 'script' tag Firefox encounters when loading a page.

The thing is, I don't know even which line in the webpage code the scripts starts at, since it is a heavily dynamic page which changes every time you reload it.

Is it possible to achieve?

Hello, everyone. My question is the following: I am using an inspector/debugger from the Firefox Development Tools. (Triggered by F12) What I need is to set a breakpoint on the first line of the first 'script' tag Firefox encounters when loading a page. The thing is, I don't know even which line in the webpage code the scripts starts at, since it is a heavily dynamic page which changes every time you reload it. Is it possible to achieve?

Alle antwurden (5)

more options

If you are talking about adding a breakpoint to Javascript, you would need to use a Javascript code bookmarklet to scan the entire page and add break; inside of the first script. Unfortunately, this wouldn't stop all of the scripts, as many web developers use multiple script blocks in HTML. Also, it probably wouldn't stop script files outside of the HTML code from loading. And it would also be a very taxing process for your code to look through an entire HTML page each time it loads.

If I may ask, for what purpose do you wish to make their modifications to the pages that you visit? There may be an addon that can achieve what you want.

Thanks.

Bewurke troch Wesley Branton op

more options

Well... did you actually mean to add 'debugger();' to the code?

Generally, it seems a good idea to rewrite all 'script' tags in a page to include a breakpoint, but could you expand your answer a bit more: how do I make my script process a webpage ~before~ everything else starts to load?

My first thought is Greasemonkey, but I am not sure it can be forced to run in the exact moment when the page code has been downloaded, but has not yet been parsed.

I would also have to stop pipelining and multithreading, right?

more options

As I investigate this further, I think that what you are trying to achieve may not be possible because it would need to be loaded before the webpage is rendered in the browser.

more options

Here is a website with some further information on setting a Javascript breakpoint. The steps can be done using Firebug:

more options

Lockywolf said

My first thought is Greasemonkey, but I am not sure it can be forced to run in the exact moment when the page code has been downloaded, but has not yet been parsed.

Probably not at that exact moment:

https://wiki.greasespot.net/Metadata_Block#.40run-at

https://wiki.greasespot.net/DOMContentLoaded

Here's an old thread on StackOverflow about doing it with Firebug, but so much can change in 7 years that it may be completely obsolete: http://stackoverflow.com/questions/1938397/telling-firebug-to-break-as-soon-as-any-javascript-is-executed