码迷,mamicode.com
首页 > 移动开发 > 详细

[Angular 8] Take away: Tools for Fast Angular Applications

时间:2019-05-07 00:55:56      阅读:183      评论:0      收藏:0      [点我收藏+]

标签:height   like   support   browser   name   fast   too   color   javascrip   

Based on the talk from NG-CONF. Check it out by yourself, here is just my own take away :)

 

Differential loading:

The basic idea is that, Angular will build tow version of Javascript bundle. One is ES5 version to support all browsers, another one is ES2015 version, with latest JS features, it results out smaller bundler size, faster execution.

Then for the browser, it will based on the script type to choose which version to download:

<script type="module" src="app-es2015.js"></script>
<script nomodule src="app-es5.js"></script>

 

To achieve that, we need to update ‘target‘ in tsconfig.json to ‘es2015‘. This helps to support morden browsers.

And set the minimum support browsers in ‘browserlist‘.

 

Code splitting:

1. Dynamic import for Route level lazy load:

技术图片

 

2. Component level lazy load:

https://www.npmjs.com/package/ngx-loadable

or

https://www.npmjs.com/package/@herodevs/lazy-af

Personally, I like ngx-loadable API more.

 

3. Pre-fetching:

4. Performance Budgets:

You can set a budgets for entire app or some centern parts:  https://github.com/angular/angular-cli/blob/master/docs/documentation/stories/budgets.md

{
  ...
  "configurations": {
    "production": {
      ...
      budgets: [
        {
          "type": "bundle",
          "name": "vendor",
          "minimumWarning": "300kb",
          "minimumError": "400kb",
        }
      ]
    }
  }
}

 

   

[Angular 8] Take away: Tools for Fast Angular Applications

标签:height   like   support   browser   name   fast   too   color   javascrip   

原文地址:https://www.cnblogs.com/Answer1215/p/10823055.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!