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

322
Vistas
Synchronous download text file JavaScript

I'm making a really light weight web page that downloads a file and then displays content based on the file. There is no displayed content without the file, and I have no plans to scale up this webpage. I do not want to use async methods unless I absolutely have to.

How do you download a file in such a way that JavaScript will pause until the file is downloaded.

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

0

Just wrap your entire script in an async IIFE and await the single network request:

// immediately invoked async function expression:
(async () => {
  // all of your sync code before the fetch request to get the file

  const response = await fetch(url);
  // handle response, parse data, etc.

  // all of the rest of your sync code after the fetch request,
  // which won't execute until after the fetch promise is
  // resolved as the response (or rejected)
})();
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