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

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:

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

 

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

上一篇:vue项目中使用mockjs+axios模拟后台数据返回


下一篇:jsonp跨域访问的原理及参数作用