JavaScript equivalent for the old ActionScript getBytesLoaded, getBytesTotal?

I’m working on a project that will be loading many external images and other media files from a server and I was curious if there’s any sort of way to track how large the file is and how much of the file has downloaded. I’ve been looking on StackOverflow but have yet to find a definitive solution.

Have a look at Pace
https://github.hubspot.com/pace/docs/welcome/

Documentation:
https://github.hubspot.com/pace/

Update: Just saw that code is 5-6 years old :frowning:

1 Like

@MaxZieb if it still works, I’m not concerned with how old it is :smile:

2 Likes

There’s an onprogress handler, but I don’t think it works with <img> tags in most browsers currently. It does work with AJAX requests, so examples I’ve seen online download an image by that means and then convert it to a base64 string to use in a data URL.

1 Like

@jonathan - thank you! I’ll give it a try. If not, I’ll adhere to my default philosophy “fake it till you make it”

1 Like

did it work?