idle-task

Improve your website performance by executing JavaScript during a browser's idle periods. (by hiroki0525)

Idle-task Alternatives

Similar projects and alternatives to idle-task based on common topics and language

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a better idle-task alternative or higher similarity.

idle-task reviews and mentions

Posts with mentions or reviews of idle-task. We have used some of these posts to build our list of alternatives and similar projects. The last one was on 2022-11-24.
  • Show HN: Speed up your site by running JavaScript when the browser is idle
    4 projects | news.ycombinator.com | 24 Nov 2022
    `idle-task` has shim as below .

    https://github.com/hiroki0525/idle-task/blob/main/src/index....

    References

    4 projects | news.ycombinator.com | 24 Nov 2022
    The code: https://github.com/hiroki0525/idle-task/blob/main/src/index....

    Some initial impressions (based on https://github.com/hiroki0525/idle-task/blob/7e88c8b97c926cf...):

    • The cancelIdleCallback fallback implementation will never be defined (delete lines 14–15).

    • That the fallback implementation ships a modifying polyfill is not nice, if not clearly stated. Typically better to define it as a local, e.g. `const rIC = typeof requestIdleCallback !== "undefined" ? requestIdleCallback : function …` and subsequently use rIC instead of requestIdleCallback. (Related, I’m not sure quite why you only install the polyfill if self is a thing, are you deliberately ensuring you can’t use this in Node?)

    • The default code path is broken, process.env.NODE_ENV will fail in normal browser environments since process is undefined. (And no, no build process gets rid of this, fetch the distributed package and see that its index.js still contains it.)

    • Line 74, don’t return a value from a private function if none of the uses use that value; just drop the return keyword.

    • Lines 86–93, splitting logArgs out doesn’t make sense to me, it’s functionally harmless, but needless bloat. (I am perennially disappointed at the utterly primitive state of JavaScript bundlers/optimisers/minifiers: especially with TypeScript knowledge of the interfaces being touched, reordering and inlining is a trivial and obvious optimisation that only changes behaviour on bonkers code that deserves to get broken, but no tool will do it, though Closure Compiler’s advanced optimisations mode might be able to be coaxed into doing it—if it even supports spread syntax.)

    • The vibe I’m getting is that this works with a mixture of callbacks and promises, and ends up complicated because of it, parts of it feeling like the ’90s and parts like the mid-’10s. The modern approach would be to use abort signals, which… eh, they’re simpler in some cases, more complicated in others. But from this library’s perspective, you could replace the entire interface with just one promise-returning function, which I’d name schedule(task, options), with options including {signal: AbortSignal}. Cancellation would be handled a bit differently, but it’d be more flexible, because it’s left up to the caller how they hook cancellation up (want to be able to cancel a subset of all the tasks together? Easy, give them the same signal). And I think the code of this library would be simplified by going all in on such a pattern.

Stats

Basic idle-task repo stats
2
13
10.0
2 days ago

hiroki0525/idle-task is an open source project licensed under MIT License which is an OSI approved license.

Workflow assistant built for devs & their teams
Automate the mundane part of your day, with live actionable messages for your GitHub & Jira tasks.
www.zigi.ai