Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

180
Vistas
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) {
  something_like_return
}

// 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?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

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: {
    console.log('before');
    if (true) break label;
    console.log('after');
}

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda