优化应用程序的启动时间:
优化应用程序的性能:
Sencha Touch 跟Ext js一个提供了丰富且高级的组件让我们能快速的开发出一个跨手机平台而且
很绚丽的产品,这听起来不错,但很快我们发现了一个严重的问题,手机上的效果根本没有在PC上用
chrome打开的效果一样让人有刷刷的快感,甚至让人痛苦. Sencha Touch和ext一样,组件是类式继
承的,大大降低了使用和学习的周期.但缺点也是很明显的,你每增加一个组件,内存消耗就增加很多,
可能你已经使用minify/JSBuilder/YUI compressor等工具压缩过你的代码了,如果性能还不佳,那么
可以看看以下是个人的一点建议
1.每个组件都应该考虑它的xtype,如果可以使用container就不要使用一个panel了
2.list一列的个数显示一屏就可以了,list有很多高级的功能,但性能非常的差,只能通过减少加载
项来解决
3.尽量不要使用tbar/bbar,Sencha Touch的提供的toolbar功能强大,按钮也很易用,但使用的DOM元
素也非常的多,自己写一个bar是非常必要的
4.把不在置顶的view中的DOM给删除,有时候,我们的项目中有好几个view,但我们一时间内是不可能
同时查看两个view的,应该把其他view的DOM元素给释放了
从上面看来,性能优化的关键是控制DOM元素的数量,但Sencha Touch还会对一些元素绑定事件,如何
开始就不显示这些元素,那么内存开销会更低
Via :http://blog.techferry.com/2012/11/16/sencha-touch-performance-improvement-tips/
A website designed for desktop browsers can take up to 40 seconds to load on mobile devices. Your Sencha Touch application if not built and deployed properly may take more than a minute to load – a far cry from an optimized mobile site. If your Sencha Touch mobile app is taking too long to load on a mobile device, here are a few things you can consider to improve the performance.
Ext.require(['Ext.data.proxy.Rest', 'Ext.dataview.NestedList', 'Ext.TitleBar' ]); Ext.application({ name: 'MyApp', views: ['View1', 'View2'], models: ['Model1','Model2'], stores:['Store1','Store2'], launch: function() { // Do your stuff here. } });
Via :http://thatdeveloper.blogspot.com/2012/07/sencha-touch-optimization.html
http://www.sencha.com/blog/sencha-touch-optimizing-memory-usage/
http://www.sencha.com/forum/showthread.php?184180-Optimize-DOM-size-using-TabPanel
http://www.sencha.com/forum/showthread.php?101813-Great-article-for-tips-on-optimizing-performance-on-the-iPhone-and-iPad
http://www.senchatouchbits.com/10/performance-optimization.html
Some key things to watch out for:
There are a few things you can try:
Turn on hardware acceleration by adding android:hardwareAccelerated="true" to the application or activity tag in the Android manifest file. More info here:http://developer.android.com/guide/topics/graphics/hardware-accel.html
Modify the RenderPriority of the webview -http://developer.android.com/reference/android/webkit/WebSettings.RenderPriority.html
Optimize your javaScript and CSS to minimize the number of reflows, memory used, and DOM size -http://www.html5rocks.com/en/mobile/mobifying.html#toc-optimizations
Personally, I found that keeping the DOM as small as possible, and enabling hardware acceleration made all of the difference between an unusable app, and a fairly smooth app.
Try the following for the best performance for android devices:
How are you preventing overscroll in your views? Can't see it in the docs!http://docs.sencha.com/touch/2-0/#!/...croll.Scroller
setting the scroller to this sorts it:
scroller: { direction: 'vertical', directionLock: true, momentumEasing: { momentum: { acceleration: 30, friction: 0.5 }, bounce: { acceleration: 0.0001, springTension: 0.9999 }, minVelocity: 5 }, outOfBoundRestrictFactor: 0 }
技巧:
避免使用CSS3 渐变等样式,用扁平样式代替
用低分辨率代替高分辨率图片
滚动List清单限制在30-40个以内
提升Panel面板的过度和响应能力:采用隐藏或显示组件,组装Form数据,动态组装数据到面板Panel
将js文件编译成一个单独的文件app-all.js
设计平衡,要专注交付一个快速响应的,而尽量避免CSS3效果,以简单开始,逐渐增加功能确认没有重大性能问题,在Chrome浏览器里开发,在模拟器或设备里进行测试