You cannot make a truly custom asynchronous function. You’ll eventually have to leverage on a technology provided natively, such as:
setInterval
setTimeout
requestAnimationFrame
XMLHttpRequest
WebSocket
Worker
- Some HTML5 APIs such as the File API, Web Database API
- Technologies that support
onload
- … many others
In fact, for the animation jQuery uses setInterval
.