Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Progress of loading external JS file

I'm not sure what this would be called to know what to search for, if this is a duplicate please link me :)

Is it possible in JavaScript in a browser, to load an external file (this bit is easy), but given that the external file could be rather large (say 50MB) show a progress indicator of the loading of that file?

i.e I, knowing the serverside size of the file, not knowing the gzip size, I want to say X% of file loaded.

I've not tried anything, I can't find anything to work from let alone find something that suggests its possible.

Problem: Trying to load up a 50MB JavaScript library on demand but show the progress of the loading.

like image 890
Phill Avatar asked Nov 16 '13 05:11

Phill


People also ask

How do I run a JavaScript file externally?

To include an external JavaScript file, we can use the script tag with the attribute src . You've already used the src attribute when using images. The value for the src attribute should be the path to your JavaScript file. This script tag should be included between the <head> tags in your HTML document.

How does external JavaScript work?

External JavaScript is when the JavaScript Code(script) is written in another file having an extension . js and then we link this file inside the <head> or<body> tag of our HTML file in which the code is to be added.


1 Answers

Use XMLHttpRequest to load the script and monitor its progress. When it's done, eval() it.

like image 115
Jason Barnabe Avatar answered Sep 28 '22 05:09

Jason Barnabe