[SOLVED] Early return from a script (without a function)


I have multiple duplicated external scripts that I want to run just once.

I would like to return early on those scripts after the first time doing a small modification to those scripts, something like:

if (window.this_script_have_been_loaded) {

// rest of script

window.this_script_have_been_loaded = true

But I do not want to add a big if or function around the existing code to make it easier to manage. Is there a return statement for scripts?


To prevent code from running, place this code inside a block statement and exit this block if needed with a break statement and a label.

label: {
    if (true) break label;

Answered By – Nina Scholz

Answer Checked By – Marie Seifert (BugsFixing Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *