Guest User

Untitled

a guest
Mar 17th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>ES6 and Legacy bundle loading</title>
  5. </head>
  6. <body>
  7. Hi
  8. <script>
  9. // populate this on the server or via webpack
  10. window.__APP_CHUNKS__ = {
  11. es: [
  12. '/main.js',
  13. '/first.chunk.js',
  14. '/second.chunk.js'
  15. ],
  16. legacy: [
  17. '/main.legacy.js',
  18. '/first.legacy.chunk.js',
  19. '/second.legacy.chunk.js'
  20. ]
  21. };
  22. // load correct bundles
  23. var s=document.createElement('script');var c=[];if(s.noModule===false)
  24. {window.__APP_CHUNKS__.es.forEach(function(h){var n=document.createElement('script');
  25. n.setAttribute('src', h);c.push(n);});}else{window.__APP_CHUNKS__.legacy.forEach(
  26. function(b){var g=document.createElement('script');g.setAttribute('src', b);c.push(g);
  27. });};c.forEach(function(v){v.setAttribute('defer',true);document.body.appendChild(v);});
  28. </script>
  29. </body>
  30. </html>
Add Comment
Please, Sign In to add comment