'Vue Detect when a file start download in browser

I have an Mp4 file URL that I play in videojs player, in addition, I'm also giving the user the option to download the MP4 file by clicking on a download button inside the player, in order to do so I'm doing something like this:

  window.location.replace(this.src);

where this.src is the link to the MP4 file coming from AWS S3.

But when the user clicks the download button it could take several seconds until the download actually begins and I want to show a loader in order to prevent the user from clicking several times. How can I detect when the download is actually starting (so know when to stop showing the loader)? Is there any Chrome API to do so?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source