Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript The Solution

why doesn't my browser sometimes not work when i reload the page using javascript or css?E.g. with the prompt method

or with the alert statement even when the code has all its syntax correctly written

1 Answer

Justin Cox
Justin Cox
12,123 Points

I hope I'm understanding your question correctly. If so, the answer has to do with the blocking nature of the JavaScript language. Synchronous code holds up the browser until it finishes processing (such as alert() and prompt(), among others) which can be detrimental. In these cases, you would need to rewrite your code in an asynchronous manner.

Here's an article you can read to help explain blocking and non-blocking code:

https://dev.to/steelvoltage/if-javascript-is-single-threaded-how-is-it-asynchronous-56gd

I hope this helps!