<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/how-js-works-part-3-javascript-optimization-strategies-mnkuhaedz" -->

---
title: How JS Works — Part 3: JavaScript Optimization Strategies
description: Modern JavaScript engines achieve near-compiled-language performance through Just-In-Time (JIT) compilation, which combines the fast startup of interpretation...
canonical: https://daily.dev/posts/how-js-works-part-3-javascript-optimization-strategies-mnkuhaedz
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: How JS Works — Part 3: JavaScript Optimization Strategies | daily.dev
og:description: Modern JavaScript engines achieve near-compiled-language performance through Just-In-Time (JIT) compilation, which combines the fast startup of interpretation...
og:url: https://daily.dev/posts/how-js-works-part-3-javascript-optimization-strategies-mnkuhaedz
og:image: https://api.daily.dev/og/posts/mNkuhAEdz.png
og:image:alt: How JS Works — Part 3: JavaScript Optimization Strategies
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.

# How JS Works — Part 3: JavaScript Optimization Strategies

**[Medium](https://daily.dev/sources/medium_js)** · 10 min read · 3 upvotes · 0 comments

## Summary

Modern JavaScript engines achieve near-compiled-language performance through Just-In-Time (JIT) compilation, which combines the fast startup of interpretation with the execution speed of compilation. Engines like V8 use a two-phase approach: first generating unoptimized bytecode for immediate execution (via Ignition), then recompiling hot code paths into optimized machine code in background threads (via TurboFan). Additional techniques like function inlining eliminate call stack overhead for frequently-called functions. Developers can further help by batching DOM updates and reducing unnecessary function calls, especially inside loops.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://medium.com/@shamavachar20/how-js-works-part-3-javascript-optimization-strategies-c1b6c791be5c>

## Questions this post answers

### What is Just-In-Time (JIT) compilation in JavaScript and why does it make code faster?

JIT compilation combines the strengths of compilation and interpretation: the engine generates unoptimized machine code quickly so execution can start immediately, then monitors which code runs frequently ('hot' code) and recompiles those sections into faster machine code in the background. This avoids the startup delay of full compilation while still being faster than pure line-by-line interpretation.

_Explore more explainers on JavaScript engine internals and performance tuning through daily.dev._

### What is function inlining and how does it speed up JavaScript execution?

Inlining is when a JavaScript engine replaces a function call with the actual code from inside that function directly at the call site, eliminating the overhead of creating a call, pushing it onto the call stack, and returning from it. Engines apply this automatically to frequently called functions, such as ones inside loops, and developers cannot force it manually.

_Developers optimizing hot loops can track engine-level techniques like inlining via daily.dev._

### Why is frequent DOM manipulation slow in JavaScript and how should I batch updates?

Every DOM modification can trigger layout recalculation and repainting, which are far more expensive than regular JavaScript operations like math or string handling. Instead of appending to innerHTML multiple times in a loop, building the full string first and updating the DOM once reduces the browser's layout and repaint work from multiple passes down to a single pass.

_For patterns on writing efficient DOM-heavy code, daily.dev surfaces practical performance guidance._

## Similar posts on daily.dev

- [V8 Engine: The Journey of JavaScript from Code to Execution](https://daily.dev/posts/v8-engine-the-journey-of-javascript-from-code-to-execution-junca4frw) · JavaScript in Plain English · 0 upvotes · 0 comments
- [How JavaScript learned to cheat — A Deep Dive into the JS Engine](https://daily.dev/posts/how-javascript-learned-to-cheat-a-deep-dive-into-the-js-engine-aqrk9b7iq) · Medium · 1 upvotes · 0 comments

---

Tags: [#javascript](https://daily.dev/tags/javascript), [#performance](https://daily.dev/tags/performance), [#v8](https://daily.dev/tags/v8), [#compiler-optimization](https://daily.dev/tags/compiler-optimization)

[View this post on daily.dev](https://daily.dev/posts/how-js-works-part-3-javascript-optimization-strategies-mnkuhaedz)

```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":"How JS Works — Part 3: JavaScript Optimization Strategies","url":"https://daily.dev/posts/how-js-works-part-3-javascript-optimization-strategies-mnkuhaedz","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/how-js-works-part-3-javascript-optimization-strategies-mnkuhaedz"},"datePublished":"2026-07-26T13:11:40.145Z","dateModified":"2026-09-13T20:54:59.353Z","description":"Modern JavaScript engines achieve near-compiled-language performance through Just-In-Time (JIT) compilation, which combines the fast startup of interpretation...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/1bbecf13707c2e52a62167e088991ff4?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/1bbecf13707c2e52a62167e088991ff4?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Medium","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":"Medium","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/medium","url":"https://daily.dev/sources/medium_js"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/how-js-works-part-3-javascript-optimization-strategies-mnkuhaedz","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":3},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"javascript,performance,v8,compiler-optimization","timeRequired":"PT10M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Medium","item":"https://daily.dev/sources/medium_js"},{"@type":"ListItem","position":3,"name":"How JS Works — Part 3: JavaScript Optimization Strategies"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/how-js-works-part-3-javascript-optimization-strategies-mnkuhaedz#faq","mainEntity":[{"@type":"Question","name":"What is Just-In-Time (JIT) compilation in JavaScript and why does it make code faster?","acceptedAnswer":{"@type":"Answer","text":"JIT compilation combines the strengths of compilation and interpretation: the engine generates unoptimized machine code quickly so execution can start immediately, then monitors which code runs frequently ('hot' code) and recompiles those sections into faster machine code in the background. This avoids the startup delay of full compilation while still being faster than pure line-by-line interpretation. Explore more explainers on JavaScript engine internals and performance tuning through daily.dev."}},{"@type":"Question","name":"What is function inlining and how does it speed up JavaScript execution?","acceptedAnswer":{"@type":"Answer","text":"Inlining is when a JavaScript engine replaces a function call with the actual code from inside that function directly at the call site, eliminating the overhead of creating a call, pushing it onto the call stack, and returning from it. Engines apply this automatically to frequently called functions, such as ones inside loops, and developers cannot force it manually. Developers optimizing hot loops can track engine-level techniques like inlining via daily.dev."}},{"@type":"Question","name":"Why is frequent DOM manipulation slow in JavaScript and how should I batch updates?","acceptedAnswer":{"@type":"Answer","text":"Every DOM modification can trigger layout recalculation and repainting, which are far more expensive than regular JavaScript operations like math or string handling. Instead of appending to innerHTML multiple times in a loop, building the full string first and updating the DOM once reduces the browser's layout and repaint work from multiple passes down to a single pass. For patterns on writing efficient DOM-heavy code, daily.dev surfaces practical performance guidance."}}]}
```

