[Angular] Some performance tips
The talk from here.
1. The lifecycle in Angular component:

constructor vs ngOnInit:
Constructor: only used for injection.
ngOnInit: for data initlization.
About ngOnInit:

I am not sure the example is good or not. Because it is not a good choice to use 'document.querySelector'.
this.elDuceDateContainer = document.querySelector('.dueDatePopover-container')
I would rather use 'ref' or '@ViewChild'. But might be it is a good adivse that avoid init too many variable in ngOnInit if not going to use right away.

You have to know that why change detection works. It handle async code and setTimeout, setTimeInterval, DOM event, mouse event... they are all async opreations.
So it will trigger change detection.
If you have to use setTimeout in your component, and you don't want change detection to detect the changes, you can use NgZone to make it run outside the change detection.
constructor(private ngZone: NgZone) {}
ngAfterViewInit() {
this.ngZone.runOutsideAngular(() => this.paint());
}

Noramlly I won't use any jQuery plugin. But take this as an advise.
[Angular] Some performance tips的更多相关文章
- Android 性能优化(19)*代码优化11条技巧:Performance Tips
Performance Tips 1.In this document Avoid Creating Unnecessary Objects 避免多余的对象 Prefer Static Over Vi ...
- SQL Server performance tips
Refer to: http://harriyott.com/2006/01/sql-server-performance-tips A colleague of mine has been look ...
- Performance tips
HTML5 Techniques for Optimizing Mobile Performance Scrolling Performance layout-performance
- Json.NET Performance Tips
原文: http://www.newtonsoft.com/json/help/html/Performance.htm To keep an application consistently fas ...
- [Angular] Increasing Performance by using Pipe
For example you make a function to get rating; getRating(score: number): string { let rating: string ...
- 翻译--Blazing fast node.js: 10 performance tips from LinkedIn Mobile
1.避免使用同步代码: // Good: write files asynchronously fs.writeFile('message.txt', 'Hello Node', function ( ...
- [Javascript]3. Improve you speed! Performance Tips
/** Let inheritance help with memory efficiency */ function SignalFire(ID, startingLogs){ this.fireI ...
- 10个加速Table Views开发的Tips(转)
本文由CocoaChina译者yake_099(博客)翻译,作者:David McGraw原文:10 Actionable Performance Tips To Speed Up Your Tabl ...
- 【原创】大数据基础之Hive(5)性能调优Performance Tuning
1 compress & mr hive默认的execution engine是mr hive> set hive.execution.engine;hive.execution.eng ...
随机推荐
- 手把手教你用NDK9编译ffmpeg2.4.2
编译环境: 32位 ubuntu12.10 android-ndk-r9c-linux-x86.tar.bz2 ffmpeg-2.4.2.tar.bz2 网上的教程都是以低版本号ffmpeg编译居多. ...
- bootstrap课程9 bootstrap如何实现动画加载进度条的效果
bootstrap课程9 bootstrap如何实现动画加载进度条的效果 一.总结 一句话总结:在bootstrap进度条的基础上添加js(定时器),动态的改变进度条即可.很简单的. 1.路径导航是什 ...
- 25.Spring @Transactional工作原理
转自:http://www.importnew.com/12300.html 本文将深入研究Spring的事务管理.主要介绍@Transactional在底层是如何工作的.之后的文章将介绍: prop ...
- Cronolog 分割 Tomcat8 Catalina.out日志 (转)
默认情况下,tomcat的catalina.out日志文件是没有像其它日志一样,按日期进行分割,而是全部输出全部写入到一个catalina.out,这样日积月累就会造成.out日志越来越大,给管理造成 ...
- update进行跨表之间的更新
有时我们可能须要多个表之间进行更新数据. 我们能够使用这个语句 UPDATE table1,table2 SET table1.column=table2.column, table1.column1 ...
- FZU Problem 2168 防守阵地 I
http://acm.fzu.edu.cn/problem.php?pid=2168 题目大意: 给定n个数和m,要求从n个数中选择连续的m个,使得a[i]*1+a[i+1]*2+--a[i+m]*m ...
- HibernateCRUD基础框架(2)-HQL语句构造器(HqlQueryBuilder,HqlUpdateBuilder)
上篇讲述了最基本的实体类,本篇接着讲述HQL语句构造器,包括查询和更新等. 优点:通过面向对象的方式构造HQL语句,更快捷,不需要手动拼接HQL. 缺点:封装可能降低性能,只能支持常用的和较为简单的H ...
- 【例题 6-19 UVA - 1572】Self-Assembly
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 旋转和翻转,会发现. 如果可以顺着某个方向一直放的话. 总是能转换成往下或者往右连的. 则只要能够出现一个连接顺序的循环,则总是有解 ...
- flask的使用(一)
1.程序基本的说明 #-*-encoding=utf--*- 从flask中引入类 from flask import Flask ,render_template import config 初始化 ...
- v-if和updated钩子结合使用 渲染echart图表
项目需求是这样的,用户可以自定选择echart 曲线图 是横向还是竖向显示.我的做法是 写了一个横向的echart图表,也写了一个竖向的echart图表,然后两者共用存在store里的图表数据,就能实 ...