Sean
Sean

Reputation: 183

Is it possible to obtain the download progress of an dynamically loaded javascript file?

I'd like to load a basic homepage for a web-app which asynchronously loads a large javascript file (the guts of the application).

Can I retrieve the download progress of this js file?

I would like to display a loading bar that accurately reflects the download progress, then when the script has finished enable a 'launch' button.

I normally use jquery but am happy for any solutions! I'll be using a php backend if that helps.

Upvotes: 4

Views: 719

Answers (1)

James Black
James Black

Reputation: 41858

This won't work on all browsers, but you can use the <progress> tag in HTML5.

http://blog.greweb.fr/2012/04/work-in-progress/

You can also use the progress event for the connection.

https://developer.mozilla.org/En/Using_XMLHttpRequest#Monitoring_progress

Upvotes: 1

Related Questions