xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

idle & js

idle meaning in js

https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/idle


// var handle = window.requestIdleCallback(callback[, options])


const handle = window.requestIdleCallback(
    (IdleDeadline) => console.log(`handle =`, window.handle, IdleDeadline),
    {
         timeout: 1000,// mm
    }
);

// handle = 13 IdleDeadline {didTimeout: false}

// didTimeout: false__proto__: IdleDeadlinedidTimeout: (...)timeRemaining: ƒ timeRemaining()constructor: ƒ IdleDeadline()Symbol(Symbol.toStringTag): "IdleDeadline"get didTimeout: ƒ didTimeout()__proto__: Objectconstructor: ƒ Object()hasOwnProperty: ƒ hasOwnProperty()isPrototypeOf: ƒ isPrototypeOf()propertyIsEnumerable: ƒ propertyIsEnumerable()toLocaleString: ƒ toLocaleString()toString: ƒ toString()valueOf: ƒ valueOf()__defineGetter__: ƒ __defineGetter__()__defineSetter__: ƒ __defineSetter__()__lookupGetter__: ƒ __lookupGetter__()__lookupSetter__: ƒ __lookupSetter__()get __proto__: ƒ __proto__()set __proto__: ƒ __proto__()

window.cancelIdleCallback(handle);



https://developers.google.com/web/updates/2015/08/using-requestidlecallback

https://stackoverflow.com/questions/20702940/what-does-idle-mean-in-google-chrome-devtools-profiler

https://dev.to/canastro/javascript-long-running-tasks-use-cpu-s-idle-periods-58g2

Window.requestIdleCallback

https://developer.mozilla.org/en-US/docs/Web/API/Window/requestIdleCallback


// var handle = window.requestIdleCallback(callback[, options])
var handle = window.requestIdleCallback(
	() => console.log(`handle =`, window.handle),
	{
		timeout: 1000,// mm
    }
);

// handle = 1

window.cancelIdleCallback(handle);

https://developer.mozilla.org/zh-CN/docs/Web/API/Window/cancelIdleCallback

https://caniuse.com/#search=requestIdle

https://humanwhocodes.com/blog/2009/06/02/detecting-if-the-user-is-idle-with-javascript-and-yui-3/

https://github.com/pixijs/pixi.js/issues/3146

https://github.com/googleapis/cloud-profiler-nodejs/issues/38

An UMD lib to know when a page goes idle: hidden, or inactive.

https://www.npmjs.com/package/idle-js


idle & dart & flutter

image

https://dart-lang.github.io/observatory/


Flag Counter

©xgqfrms 2012-2020

www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!


原文地址:https://www.cnblogs.com/xgqfrms/p/11433168.html