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

242
Vistas
what is the fastest way to use fetch or a faster alternative?

I have a server where quickfire requests are sent to it from a static app. I previously used fetch to get data from the server, but noticed that is was very slow, often delaying the service by 60ms per request. I need the text from the server. My server is hosted on a free plan, so it goes to sleep. I have to send a http request to my host to start it up, which takes a few seconds. I don't mind the few seconds of loading time, since the server only sleeps after an hour of inactivity, but the delay of 60ms per request really slows the app down. I have been doing this (I cant do await on static apps and I cant do async functions because then I would need to rewrite a lot of stuff in my app):

fetch('https://server.freenodejshost.com').then(r=>{
r.text().then(txt=>{
//do something with the info
})
})

Is there any way to use fetch faster? Or is there a faster alternative to fetch?

about 4 years ago · Santiago Gelvez
1 Respuestas
Responde la pregunta

0

Check out the benchmark test below. XHR works faster than fetch in most cases.

XHR:

const xhr = new XMLHttpRequest();
xhr.open('GET', 'https://www.googleapis.com/discovery/v1/apis');
xhr.onload = () => console.log(JSON.parse(xhr.responseText));
xhr.send();

fetch:

fetch('https://www.googleapis.com/discovery/v1/apis').then(response => response.json()).then(console.log)

ref: measurethat.net/Benchmarks/Show/6254/0/xhr-vs-fetch

about 4 years ago · Santiago Gelvez 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