Guest User

Untitled

a guest
Dec 14th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. console.log('progress at 0 %') // at the top
  2. // code to update the progress bar
  3.  
  4. console.log('progress at 23 %') // Somewhere else
  5. // code to update the progress bar
  6.  
  7. var appScript = document.createElement('script')
  8. var xhr = new XMLHttpRequest();
  9. xhr.addEventListener('progress', function (e) {
  10. var percent = e.loaded / e.total
  11. console.log('loaded', percent)
  12. // update loader
  13. })
  14. xhr.addEventListener('load', function () {
  15. appScript.innerHTML = this.responseText
  16. document.body.appendChild(appScript)
  17. // ^ at this point the app javascript will run
  18. })
  19. xhr.open('GET', '/js/app.js')
  20. xhr.send()
Add Comment
Please, Sign In to add comment