Because JS has a single call stack and the loop occupies it. The event loop cannot push queued callbacks (clicks, timers, animation frames) until the loop finishes, so the UI cannot respond.
Synchronous Execution in JavaScript Explained
Why does a long loop freeze the browser UI?
The answer
More FAQs in Synchronous Execution in JavaScript Explained
Each statement runs one at a time, in order, on a single call stack. The next line waits for the previous line to finish before it can run.
All other work stops. Click handlers, timers, and animations cannot run until the blocking function returns. The UI freezes for the duration.
Asynchronous. fetch returns a Promise immediately. The network call runs in a Web API, and the .then callback runs on the call stack only when the stack is empty.
Still have questions?
Browse all our FAQs or reach out to our support team
Want to upskill yourself?
Your learning library
Small steps. Big possibilities.
Find your next course. Build something great.