In the below click event listener I do a HEAD request against a file to make sure it exists before I attempt to use it. It works great on desktop, but on a mobile device (I test connect to Wi-Fi), it adds ~10s delay in the JS execution. You tap a link and just nothing happens for that time, and then everything continues.
How can this be? Is there something I can change to prevent the delay?
link.addEventListener("click", async (e) => {
e.preventDefault()
const filelink = link.pathname
if((await fetch(filelink,{method: 'HEAD'})).ok == true) {
audiodlg.showModal()
player.src = filelink
document.querySelector("dialog > span").innerText = filelink.substring(filelink.lastIndexOf('/')+1)
}
9 posts - 2 participants
Read full topic
| # | Наименование новости | Тональность | Информативность | Дата публикации |
|---|---|---|---|---|
| 1 | What are the best practices for improving website performance in modern web development? | 0 | 8 | 17-09-2026 |
| 2 | I'm kopfoderzahlmnzwurf – web developer & SEO specialist | 0 | 11.87 | 18-09-2026 |
| 3 | What makes a small web utility useful and trustworthy? | 0 | 5.33 | 05-10-2026 |
| 4 | Mobile Menu Help | 0 | 8.98 | 02-10-2026 |
| 5 | Best way to build a responsive multi-field booking form? | 0 | 6.38 | 01-10-2026 |
| 6 | What’s a sensible way to handle a daily word puzzle backend in PHP? | 0 | 6.62 | 18-09-2026 |
| 7 | Elevated request latency | 0 | 14.4 | 01-10-2026 |
| 8 | How should a small service business design a simple booking flow without hurting conversions? | 0 | 8.06 | 21-09-2026 |
| 9 | Reply To: Change spacer height for mobile? | 0 | 18.14 | 01-10-2026 |