Is it possible to detect \"idle\" time in JavaScript? My primary use case probably would be to pre-fetch or preload content.
Idle time:
If you are targeting a supported browser (Chrome or Firefox as of December 2018) you can experiment with the requestIdleCallback and include the requestIdleCallback shim for unsupported browsers.