Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- console.log('progress at 0 %') // at the top
- // code to update the progress bar
- console.log('progress at 23 %') // Somewhere else
- // code to update the progress bar
- var appScript = document.createElement('script')
- var xhr = new XMLHttpRequest();
- xhr.addEventListener('progress', function (e) {
- var percent = e.loaded / e.total
- console.log('loaded', percent)
- // update loader
- })
- xhr.addEventListener('load', function () {
- appScript.innerHTML = this.responseText
- document.body.appendChild(appScript)
- // ^ at this point the app javascript will run
- })
- xhr.open('GET', '/js/app.js')
- xhr.send()
Add Comment
Please, Sign In to add comment