Skip to content

Instantly share code, notes, and snippets.

View Sauloxd's full-sized avatar
🍊
orange

Saulo Furuta Sauloxd

🍊
orange
View GitHub Profile
@Sauloxd
Sauloxd / git_create_orphan.sh
Created March 20, 2019 12:26 — forked from seanbuscay/git_create_orphan.sh
Create an orphan branch in a repo.
cd repository
git checkout --orphan orphan_name
git rm -rf .
rm '.gitignore'
echo "#Title of Readme" > README.md
git add README.md
git commit -a -m "Initial Commit"
git push origin orphan_name
@Sauloxd
Sauloxd / README.md
Created July 25, 2017 15:21 — forked from jesstelford/README.md
Starving the Event Loop with Microtasks

Starving the Event Loop with microtasks

Sparked from this twitter conversation when talking about doing fast async rendering of declarative UIs in Preact

These examples show how it's possible to starve the main event loop with microtasks (because the microtask queue is emptied at the end of every item in the event loop queue). Note that these are contrived examples, but can be reflective of situations where Promises are incorrectly expected to yield to the event loop "because they're async".

  • setTimeout-only.js is there to form a baseline
  • chained-promises.js shows the event loop being starved when many microtasks are queued at once
  • promises-returning-promises.js shows chained .then() calls starving the event loop