<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/optimize-long-tasks-zpg6qjhno" -->

---
title: Optimize long tasks | daily.dev
description: Tasks involve work such as rendering, parsing HTML and CSS, running the JavaScript code you write. The main thread is where most tasks are run in the browser....
canonical: https://daily.dev/posts/optimize-long-tasks-zpg6qjhno
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Optimize long tasks | daily.dev
og:description: Tasks involve work such as rendering, parsing HTML and CSS, running the JavaScript code you write. The main thread is where most tasks are run in the browser....
og:url: https://daily.dev/posts/optimize-long-tasks-zpg6qjhno
og:image: https://api.daily.dev/og/posts/zpg6qJhNO.png
og:image:alt: Optimize long tasks
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.

# Optimize long tasks

**[web.dev](https://daily.dev/sources/web)** · 13 min read · 11 upvotes · 0 comments

## Summary

Tasks involve work such as rendering, parsing HTML and CSS, running the JavaScript code you write. The main thread is where most tasks are run in the browser. When tasks stretch beyond a certain point, they're classified as long tasks. Using setTimeout here is problematic, because the ergonomics of it make it difficult to implement.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://web.dev/optimize-long-tasks/>

---

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

[View this post on daily.dev](https://daily.dev/posts/optimize-long-tasks-zpg6qjhno)

```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":"Optimize long tasks","url":"https://daily.dev/posts/optimize-long-tasks-zpg6qjhno","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/optimize-long-tasks-zpg6qjhno"},"datePublished":"2022-09-30T21:54:18.941Z","dateModified":"2022-09-30T21:54:18.940Z","description":"Tasks involve work such as rendering, parsing HTML and CSS, running the JavaScript code you write. The main thread is where most tasks are run in the browser....","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/d841e7b5e1ad61ef377ae9c82706680a","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/d841e7b5e1ad61ef377ae9c82706680a","isAccessibleForFree":true,"articleSection":"web.dev","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":"web.dev","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/177a1962a8a945468271068795ff0134","url":"https://daily.dev/sources/web"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/optimize-long-tasks-zpg6qjhno","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":11},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"javascript","timeRequired":"PT13M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"web.dev","item":"https://daily.dev/sources/web"},{"@type":"ListItem","position":3,"name":"Optimize long tasks"}]}
```

