🚀⚡ Awesome lists about performance related patches/PRs.
The purpose of this awesome list is to allow others to learn from performance improvements of the past 📝, so that you can submit your performance improvement sooner or later here as well 🤝.
The list also includes blog posts without PRs, if they contain enough code to make them useful for this purpose.
⭐ marks blog posts or articles covering a lot of areas with in-depth explanations.
For Web Performance, there are a few more lists of curated links of talks, newsletters, blogs and more:
➡️ fabkrum/web-performance-resources
➡️ imteekay/web-performance-research
➡️ nucliweb/webperf-snippets
Hint: What improves performance might change over time; always re-validate assumptions by using a reliable benchmarking tool such as bench-node or Tachometer.
Follow me on Twitter for updates.
Patches focused on JavaScript performance improvements. Guides:
String.prototype.split, avoid downtranspilation of for..of, hoist constants. | blog post📖Array.prototype.map with for loops, use ?. instead of ||{}length of string in while loopSet to ArraySet and MapSet to Linked Lists, adds lazy value evaluationSet with BigInt | Mastodon explainernew calls, Uint32Array + Wasm instead of BigInt, array instead of hash map to avoid hashing cost, fast path stack-based depth-first search to avoid recursion | Twitter explainerdelete, optimize for v8 hidden classes, use JS generators to allow more frequent GC collectionMap to typed arrays, uses "parallel arrays" for more efficient CPU cache usage | VideoSet with array to reduce memory consumption if uniqueness is guaranteed, discusses downsides of Map for frequent and large data sets, because of rehashing | ⭐shift an O(1) operationdelete (PR #2)Object#freeze for lower memory consumption at around equal perfvar is faster than let/const in the specific use case of TypeScriptfor..of downtranspilation & destructuring optimizationvar?.constructor !== Object, array tuples to flat arrayAsyncIterable instead of a ReadableStreamsetTimeout & cancelTimeoutsetTimeout appears more expensive than it truly is in DevTools, see thisindexOf -> slice to reduce worst-case runtime durationimport() calls (see also, tweet)Promise use, optimizes arrays to Set, replaces string.split with string.indexOf() + string.substring() and morePromise creationPromise creationuseSyncExternalStore (blog)addEventListenerpath.join with str.joinconst foo = (str) => bar(str) -> const foo = bar)new URL().searchParams, use new URLSearchParams() instead.{…base} is faster than Object.keys()TextEncode#encode N times with small strings is slower than 1x with a large stringnew URL can be expensive; use simple checks to prevent obj alloc (PR #2, PR #3)os.cpus().length is slow, prefer os.availableParallelism()for..in and pre-allocated arrays (new Array(len)) over Object.entries (PR #2)Buffer#toString instead of str += char explainerError.stackTraceLimit = 10 to make throwing Error cheaper/faster to runswitch..case statements, replace by manual instruction tables (using arrays)Symbol.isConcatSpreadable/g) and very large strings, make sure to check for memory leaks in V8/Chromium (possibly also includes other string functions like substring, slice, trim due to v8/2869requestAnimationFrame into one for DOM reads and one for DOM writesIntl.Collator might nowadays be slower.)Intl.DateTimeFormat over Date.toLocaleDateStringReadableStream'sDoubles via Number.NaN instead of 0 or null, initialize numeric fields with 0 instead of nullObject.create(Foo.prototype) over new Foo() plus getters to reduce initialization overhead>>> 0 | ⭐Object.setPrototypeOf({ ... }, null) or classes with a null prototype over Object.create(null)O(n²) to O(n)npm i significantly slower, due to expensive CLI/draw calls - solved by throttlingDOMParserPatches focused on CSS performance improvements.
z-indexrequestAnimationFrame callbacks for higher perf@property - registering @property's has a cost, but once done is faster than regular props::view-transition-group(*) animations - Optimize View Transition performance by calculating animation delta's upfronttranslate and mask instead of background-position to render text shimmersPatches focused on HTML & Core Web Vitals performance improvements.
autofocus implementation with manual focus in the next task for improved INP<body> after giving the browser a chance to paint for improved INP<img> to canvas to drastically reduce memory footprintGuides:
<svg>sJSON.parse and fake script tags for passing states from server to clientOPTIONS requestsdisplay:none first and then remove DOM nodes using requestIdleCallback; yield functions for high and background priorityPatches focused on TypeScript runtime performance improvements (e.g. running tsc). The TS team also has a dedicated wiki page. Attest can help you benchmark.
interfacesGuides 📖:
in out where possible; and moreContributions welcome! Read the contribution guidelines first.
207 followers · starred Aug 2024
5,835 followers · starred Jan 2024
421 followers · starred Oct 2024
156 followers · starred Nov 2023
🚀⚡ Awesome lists about performance related patches/PRs.
The purpose of this awesome list is to allow others to learn from performance improvements of the past 📝, so that you can submit your performance improvement sooner or later here as well 🤝.
The list also includes blog posts without PRs, if they contain enough code to make them useful for this purpose.
⭐ marks blog posts or articles covering a lot of areas with in-depth explanations.
For Web Performance, there are a few more lists of curated links of talks, newsletters, blogs and more:
➡️ fabkrum/web-performance-resources
➡️ imteekay/web-performance-research
➡️ nucliweb/webperf-snippets
Hint: What improves performance might change over time; always re-validate assumptions by using a reliable benchmarking tool such as bench-node or Tachometer.
Follow me on Twitter for updates.
Patches focused on JavaScript performance improvements. Guides:
String.prototype.split, avoid downtranspilation of for..of, hoist constants. | blog post📖Array.prototype.map with for loops, use ?. instead of ||{}length of string in while loopSet to ArraySet and MapSet to Linked Lists, adds lazy value evaluationSet with BigInt | Mastodon explainernew calls, Uint32Array + Wasm instead of BigInt, array instead of hash map to avoid hashing cost, fast path stack-based depth-first search to avoid recursion | Twitter explainerdelete, optimize for v8 hidden classes, use JS generators to allow more frequent GC collectionMap to typed arrays, uses "parallel arrays" for more efficient CPU cache usage | VideoSet with array to reduce memory consumption if uniqueness is guaranteed, discusses downsides of Map for frequent and large data sets, because of rehashing | ⭐shift an O(1) operationdelete (PR #2)Object#freeze for lower memory consumption at around equal perfvar is faster than let/const in the specific use case of TypeScriptfor..of downtranspilation & destructuring optimizationvar?.constructor !== Object, array tuples to flat arrayAsyncIterable instead of a ReadableStreamsetTimeout & cancelTimeoutsetTimeout appears more expensive than it truly is in DevTools, see thisindexOf -> slice to reduce worst-case runtime durationimport() calls (see also, tweet)Promise use, optimizes arrays to Set, replaces string.split with string.indexOf() + string.substring() and morePromise creationPromise creationuseSyncExternalStore (blog)addEventListenerpath.join with str.joinconst foo = (str) => bar(str) -> const foo = bar)new URL().searchParams, use new URLSearchParams() instead.{…base} is faster than Object.keys()TextEncode#encode N times with small strings is slower than 1x with a large stringnew URL can be expensive; use simple checks to prevent obj alloc (PR #2, PR #3)os.cpus().length is slow, prefer os.availableParallelism()for..in and pre-allocated arrays (new Array(len)) over Object.entries (PR #2)Buffer#toString instead of str += char explainerError.stackTraceLimit = 10 to make throwing Error cheaper/faster to runswitch..case statements, replace by manual instruction tables (using arrays)Symbol.isConcatSpreadable/g) and very large strings, make sure to check for memory leaks in V8/Chromium (possibly also includes other string functions like substring, slice, trim due to v8/2869requestAnimationFrame into one for DOM reads and one for DOM writesIntl.Collator might nowadays be slower.)Intl.DateTimeFormat over Date.toLocaleDateStringReadableStream'sDoubles via Number.NaN instead of 0 or null, initialize numeric fields with 0 instead of nullObject.create(Foo.prototype) over new Foo() plus getters to reduce initialization overhead>>> 0 | ⭐Object.setPrototypeOf({ ... }, null) or classes with a null prototype over Object.create(null)O(n²) to O(n)npm i significantly slower, due to expensive CLI/draw calls - solved by throttlingDOMParserPatches focused on CSS performance improvements.
z-indexrequestAnimationFrame callbacks for higher perf@property - registering @property's has a cost, but once done is faster than regular props::view-transition-group(*) animations - Optimize View Transition performance by calculating animation delta's upfronttranslate and mask instead of background-position to render text shimmersPatches focused on HTML & Core Web Vitals performance improvements.
autofocus implementation with manual focus in the next task for improved INP<body> after giving the browser a chance to paint for improved INP<img> to canvas to drastically reduce memory footprintGuides:
<svg>sJSON.parse and fake script tags for passing states from server to clientOPTIONS requestsdisplay:none first and then remove DOM nodes using requestIdleCallback; yield functions for high and background priorityPatches focused on TypeScript runtime performance improvements (e.g. running tsc). The TS team also has a dedicated wiki page. Attest can help you benchmark.
interfacesGuides 📖:
in out where possible; and moreContributions welcome! Read the contribution guidelines first.
207 followers · starred Aug 2024
5,835 followers · starred Jan 2024
421 followers · starred Oct 2024
156 followers · starred Nov 2023