Skip to content

Instantly share code, notes, and snippets.

View hellohejinyu's full-sized avatar
👋

何锦余 hellohejinyu

👋
  • Shanghai
  • 07:50 (UTC +08:00)
View GitHub Profile
@tomhicks
tomhicks / plink-plonk.js
Last active March 18, 2024 02:23
Listen to your web pages
@bluejava
bluejava / Soon (Fast)
Last active November 11, 2020 15:12
Insanely Fast Javascript thread Yield (see blog post)
// See http://www.bluejava.com/4NS/Speed-up-your-Websites-with-a-Faster-setTimeout-using-soon
// This is a very fast "asynchronous" flow control - i.e. it yields the thread and executes later,
// but not much later. It is far faster and lighter than using setTimeout(fn,0) for yielding threads.
// Its also faster than other setImmediate shims, as it uses Mutation Observer and "mainlines" successive
// calls internally.
// WARNING: This does not yield to the browser UI loop, so by using this repeatedly
// you can starve the UI and be unresponsive to the user.
// This is an even FASTER version of https://gist.github.com/bluejava/9b9542d1da2a164d0456 that gives up
// passing context and arguments, in exchange for a 25x speed increase. (Use anon function to pass context/args)
var soon = (function() {
@bluejava
bluejava / Soon
Last active December 22, 2022 06:27
A Very Fast Javascript thread yield (see blog posting)
// See http://www.bluejava.com/4NS/Speed-up-your-Websites-with-a-Faster-setTimeout-using-soon
// This is a very fast "asynchronous" flow control - i.e. it yields the thread and executes later,
// but not much later. It is far faster and lighter than using setTimeout(fn,0) for yielding threads.
// Its also faster than other setImmediate shims, as it uses Mutation Observer and "mainlines" successive
// calls internally.
// WARNING: This does not yield to the browser UI loop, so by using this repeatedly
// you can starve the UI and be unresponsive to the user.
// Note: For an even faster version, see https://gist.github.com/bluejava/b3eb39911da03a740727
var soon = (function() {