How to detect idle time in JavaScript elegantly?

前端 未结 30 2762
别跟我提以往
别跟我提以往 2020-11-21 11:51

Is it possible to detect \"idle\" time in JavaScript?
My primary use case probably would be to pre-fetch or preload content.

Idle time:

30条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-21 12:54

    I have created a small lib that does this a year ago:

    https://github.com/shawnmclean/Idle.js

    Description:

    Tiny javascript library to report activity of user in the browser (away, idle, not looking at webpage, in a different tab, etc). that is independent of any other javascript libraries such as jquery.

    Visual Studio users can get it from NuGet by: PM> Install-Package Idle.js

提交回复
热议问题