All Questions
Tagged with javascript performance
8,459 questions
0
votes
0
answers
94
views
Why does reading offsetTop / offsetHeight in a throttled scroll handler still trigger forced reflow?
I'm profiling scroll behavior in Chrome DevTools.
I have a scroll handler that is throttled. Inside the handler I calculate
the scroll progress of the page and toggle some UI elements such as a
"...
Advice
2
votes
8
replies
200
views
Does V8 optimize curried functions like a typical functional programming language?
Functional programming languages like Haskell or OCaml go though some effort to make
curried functions have reasonable performance compared to uncurried functions. I am curious if V8 has any ...
0
votes
1
answer
66
views
Time complexity analysis for a leetcode question
While solving a question in LeetCode (Longest common prefix), I used the startsWith and slice operation of JavaScript both of which are o(N) operations. But LeetCode claims the solution I submitted is ...
6
votes
1
answer
74
views
How to use useMemo with dynamic per-record paths in TypeScript React dropdown?
I'm working on a React table where each row has a dropdown with actions (Edit, Delete).
I want to optimize performance using useMemo, but I'm stuck because each row needs a
different path based on the ...
1
vote
1
answer
131
views
Why does deleting a property from a JavaScript object significantly degrade performance compared to setting it to undefined? [closed]
I've been running some micro-benchmarks in Node.js v20.10 to understand how V8 handles object property removal. I noticed a massive performance discrepancy—a "performance cliff"—that seems ...
Best practices
0
votes
3
replies
69
views
javascript: `Object.create(null)` vs `{}`
Does const obj = Object.create(null) create less overhead than just const obj = {} ?
Maybe Object.create(null) even worse for performance?
If i don't need to have properties like hasOwnProperty from ...
Best practices
1
vote
4
replies
104
views
Splitting website css and js files into smaller riles or combining them in 2025
Whilst this question has been asked many times before there are seldom recommendation on it with modern browsers in 2025.
Example:
Total CSS for a website is 200kb.
Total JS is 100kb.
We know the ...
Best practices
1
vote
2
replies
75
views
Optimising a function by caching the results or removing the function enirely?
In JavaScript, how costly is a function call? I ask because I'm looking at, at the start of a function, checking whether the results have already been calculated and, if so, just use them (assuming ...
0
votes
1
answer
204
views
Why does heavy object cloning degrade JS performance even when using structuredClone compared to manual optimization? [closed]
In a high-performance Node.js service, I noticed that structuredClone() introduces unexpected latency spikes when cloning large nested objects (30–50 KB each). Even switching to manual cloning ...
Advice
0
votes
2
replies
105
views
What prevents Javascript memory leaks in software applications?
I was thinking back to WinJS or WinUI with Windows Universal Applications (WUA) from about 10 years ago. I am wondering how it compiled and avoided typical architecture errors. If there is no memory ...
-7
votes
1
answer
204
views
How should I efficiently add all pairs in a key-value array to an object?
I have an object obj; and I then obtain an array arr of key-value pairs. Assuming that the key sets of obj and of arr are disjoint (i.e. no key appears in both) - how do I efficiently add all pairs in ...
7
votes
1
answer
152
views
Why are prototype extensions so much slower than functions?
I compared the speed of normal JavaScript functions and prototype extensions.
function NormalizeSpace(str)
{
return str.trim().replace(/\s+/g, " ");
}
String.prototype.NormalizeSpace = function ()
...
0
votes
0
answers
54
views
Sorting items in a Pina store is very slow
I have a Pinia store defined like this:
export type Era = {
id: number
name: string
start_year: number
end_year: number
item_count: number
}
const settingStore = {
eras: ref([] as Era[])...
-2
votes
1
answer
134
views
Is this a valid JavaScript approach for sorting large arrays of unique integers efficiently? [closed]
I’m experimenting with sorting large arrays of unique integers in JavaScript and came up with a simple approach. I’m curious if it’s a recognized pattern or if there are potential pitfalls I might be ...
0
votes
1
answer
140
views
Function Specific Performance Profiling
Is there a way, in Chrome or Firefox, to accurately profile the execution time of a specific function (and the functions it calls). For context, I am writing a custom renderer for an app I am working ...