<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/threading-in-javascript-0hrdorfwa" -->

---
title: Threading in JavaScript | daily.dev
description: JavaScript in the browser is famously single-threaded, unless you add web-workers, which have a very specific way of interacting with your main script. The...
canonical: https://daily.dev/posts/threading-in-javascript-0hrdorfwa
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Threading in JavaScript | daily.dev
og:description: JavaScript in the browser is famously single-threaded, unless you add web-workers, which have a very specific way of interacting with your main script. The...
og:url: https://daily.dev/posts/threading-in-javascript-0hrdorfwa
og:image: https://api.daily.dev/og/posts/0HrDorFWA.png
og:image:alt: Threading in JavaScript
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Threading in JavaScript

**[The Daily WTF](https://daily.dev/sources/thedailywtf)** · 1 min read · 13 upvotes · 5 comments

## Summary

JavaScript in the browser is famously single-threaded, unless you add web-workers, which have a very specific way of interacting with your main script. The code is stupid on its face, but it's actually advanced stupid. First off, check/assign of a variable wouldn't be atomic so the wouldn't act as a lock.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://thedailywtf.com/articles/threading-in-javascript>

## Community discussion

Top comments from developers on daily.dev.

**@henk** · 5 upvotes

> That thumbnail sums up my reaction to this quite well

**@hybit** · 0 upvotes

> ![image](https://res.cloudinary.com/daily-now/image/upload/s--KjM-AGXb--/f_auto,q_auto/v1694426207/ugc/content_d17bc9c6-05c2-4f3f-ae0a-90d52b20b238)

**@piriardo** · 0 upvotes

> the host its down

**@gherbetto** · 0 upvotes

> I became even more dead inside after this post 🌚

**@meirdev** · 0 upvotes

> tell me you suck without telling me you suck

---

Tags: [#javascript](https://daily.dev/tags/javascript)

[View this post on daily.dev](https://daily.dev/posts/threading-in-javascript-0hrdorfwa)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Threading in JavaScript","url":"https://daily.dev/posts/threading-in-javascript-0hrdorfwa","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/threading-in-javascript-0hrdorfwa"},"datePublished":"2023-09-07T10:39:47.127Z","dateModified":"2023-09-07T10:39:35.150Z","description":"JavaScript in the browser is famously single-threaded, unless you add web-workers, which have a very specific way of interacting with your main script. The...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/8b1b05f1d37d4ce032f91ef813127d14?_a=AQAEufR","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/8b1b05f1d37d4ce032f91ef813127d14?_a=AQAEufR","isAccessibleForFree":true,"articleSection":"The Daily WTF","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"The Daily WTF","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/d21a6aa61a7244d893a3b3284df8e2ef","url":"https://daily.dev/sources/thedailywtf"},"commentCount":5,"discussionUrl":"https://daily.dev/posts/threading-in-javascript-0hrdorfwa","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":13},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":5}],"keywords":"javascript","timeRequired":"PT1M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"The Daily WTF","item":"https://daily.dev/sources/thedailywtf"},{"@type":"ListItem","position":3,"name":"Threading in JavaScript"}]}
{"@context":"https://schema.org","@type":"WebPage","@id":"https://daily.dev/posts/threading-in-javascript-0hrdorfwa","comment":[{"@type":"Comment","text":"That thumbnail sums up my reaction to this quite well","datePublished":"2023-09-08T18:42:18.696Z","url":"https://daily.dev/posts/0HrDorFWA#c-Hr7hPjjm6","author":{"@type":"Person","name":"Henk","url":"https://daily.dev/henk","image":"https://media.daily.dev/image/upload/s--BNUnsnHs--/f_auto,q_auto/v1/avatars/avatar_5wKHIbnBnXQt4rjSK9CPi"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":5}},{"@type":"Comment","text":"","datePublished":"2023-09-11T09:57:14.845Z","url":"https://daily.dev/posts/0HrDorFWA#c-lrKFZjCMB","author":{"@type":"Person","name":"Tobias von Essen","url":"https://daily.dev/hybit","image":"https://media.daily.dev/image/upload/s--yhbn5KQl--/f_auto,q_auto/v1/avatars/avatar_5bfNK4zyHWgHijxrHSQUo"}},{"@type":"Comment","text":"the host its down","datePublished":"2023-09-12T14:36:53.281Z","url":"https://daily.dev/posts/0HrDorFWA#c-cA1GQhUVI","author":{"@type":"Person","name":"Rodrigo","url":"https://daily.dev/piriardo","image":"https://avatars.githubusercontent.com/u/39835451?v=4"}},{"@type":"Comment","text":"I became even more dead inside after this post 🌚","datePublished":"2023-09-15T21:45:06.139Z","url":"https://daily.dev/posts/0HrDorFWA#c-Aa1DWBsgH","author":{"@type":"Person","name":"Dmitrii Gherastovschi","url":"https://daily.dev/gherbetto","image":"https://media.daily.dev/image/upload/s--wr1pl2FQ--/f_auto,q_auto/v1/avatars/avatar_QK1rcnAGIwiRnYgxdGAR1"}},{"@type":"Comment","text":"tell me you suck without telling me you suck","datePublished":"2023-10-27T07:03:25.308Z","url":"https://daily.dev/posts/0HrDorFWA#c-HvSYT7Tis","author":{"@type":"Person","name":"Meir Ankri","url":"https://daily.dev/meirdev","image":"https://media.daily.dev/image/upload/s--O0TOmw4y--/f_auto/v1715772965/public/noProfile"}}]}
```

