Angular 2 Initial loading progress

前端 未结 3 605
暗喜
暗喜 2021-02-01 18:35

I\'ve tried my best to bring the bundle size of Angular 2 down and have been relatively successful in reducing the size to ~300kb (Angular 2 + jquery + bootstrap + some other sm

相关标签:
3条回答
  • 2021-02-01 18:48

    Here are some other things that you can do to reduce the loading time of the static resources.

    • Try a hosting solution supported by CDN such as firebase hosting - https://firebase.google.com/docs/hosting
    • Make your app a progressive web app. Progressive web apps uses service workers to cache the static resources inside user's device, so they needs to be update only when a new version of your application has been released - https://angular.io/guide/service-worker-getting-started
    0 讨论(0)
  • 2021-02-01 18:55

    You could try to add a second script in your index.html, which would then load all your other files (just as the index.html is doing now). Then you'd have a bunch of AJAX requests for your files and could add them to the DOM. To track the progress, you could try to use an HTTP HEAD request with the Content-Length header.

    0 讨论(0)
  • 2021-02-01 19:04

    I am not sure about reflect/zone.js, but for download we can follow this

    <body onload="showApp()">
        <div class="progress-bar" id="loadingContainer"></div>
        <my-app style="display: none"><my-app>
    </body>
    
    showApp() {
        document.getElementById('loadingContainer').style.display = "none";
        document.getElementsByTagName('my-app')[0].style.display = null;
    }
    
    0 讨论(0)
提交回复
热议问题