Progress of loading an external JS file

I'm not sure what this will be caused to know what to look for, if this is a duplicate, please connect me :)

Is it possible to load an external file in JavaScript in the browser (this bit is simple), but considering that the external file can be quite large (say, 50 MB), an indicator of the progress of downloading this file is displayed?

ie I, knowing the size of the serveride file, not knowing the size of gzip, I want to say that X% of the downloaded file.

I haven’t tried anything, I can’t find anything to work, not to mention find something that suggests its possibility.

Problem: Attempting to load a 50 MB JavaScript library on demand, but will show the loading progress.

+6
source share
1 answer

Use XMLHttpRequest to load the script and track its progress . When this is done, eval() it.

+4
source

Source: https://habr.com/ru/post/958183/


All Articles