简体   繁体   English

如何提高Ionic3 Anguar4应用程序的性能?

[英]How can Increase performance on my Ionic3 Anguar4 app?

Now I am working with Ionic3, Angular4 android app. 现在我正在使用Ionic3,Angular4安卓应用程序。 It is taking a while to load initially. 最初加载需要一段时间。 I mean I got a black blank screen for few seconds.How can I speed up this and avoid the black screen? 我的意思是我有一个黑色的空白屏幕几秒钟。我怎么能加快这一点,避免黑屏?

I try to keep up-to-date a post about that subject on the Ionic forum, have a look to https://forum.ionicframework.com/t/app-boot-time-current-state-and-best-practices/ 我试着在Ionic论坛上及时了解有关该主题的帖子,请访问https://forum.ionicframework.com/t/app-boot-time-current-state-and-best-practices /

But right now, some keywords about your question would be, I guess 但是现在,关于你的问题的一些关键词,我猜

  • Use lazy loading : Lazy loading concept allows you to not load and not load all requirements of your pages and components at boot time. 使用lazy loading :延迟加载概念允许您在启动时不加载和不加载页面和组件的所有要求。 For example, really really summarized, if you've got a first page1 and a page2 which use componentA . 例如,如果你有第一个page1和一个使用componentApage2 ,真的很总结。 Without lazy loading, everything gonna be loaded at boot time. 没有延迟加载,一切都将在启动时加载。 With lazy loading, componentA not gonna be loaded at boot time because it's not needed for the loading sequence and will only be use later and therefore, you save a bit of time 由于延迟加载, componentA不会在启动时加载,因为加载序列不需要它,只会在以后使用,因此节省了一些时间

  • check your code and the libs you use to spare size : Size of the app is the key. 检查你的代码和用来备用大小的库:应用程序的大小是关键。 Bigger is your app, slower is your boot 你的应用程序越大,启动速度就越慢

  • check your statics assets : could you delete or compact images? 检查您的statics assets :您可以删除或压缩图像吗? could you delete fonts? 你能删除字体吗? or could you not embed fonts? 或者你不能嵌入字体? again size is the key 再次大小是关键

  • do you use rxjs operators? 你使用rxjs运算符? recently it was announced a new way of importing them and therefore to let you only imports the one you need and not all operators, again, it allows to spare size 最近它宣布了一种新的导入方式,因此只允许你进口你需要的而不是所有的操作员,再次,它允许多余的尺寸

  • you could apply this thinking to other libs you use, like lodash or moment.js vs date-fns I guess. 你可以把这个想法应用到你使用的其他库中,比如lodash或者moment.js和date-fns我猜。 Do you import all the libs or only what you need? 你导入所有的库还是只需要你需要的库? Think small is beautiful 认为小是美丽的

I hope this helps ... 我希望这有帮助 ...

通过将应用程序分解为模块并遵循模块的lazy loading ,可以提高性能。

To improve the initial load, you must create your .APK with production configuration (if you haven't already). 要改善初始加载,必须使用生产配置创建.APK(如果尚未创建)。

To accomplish that, run the command on the command interface you are using, and accord to the OS you are targeting: 要完成此操作,请在您使用的命令界面上运行该命令,并根据您要定位的操作系统:

ionic cordova build android --prod 离子cordova构建android --prod

ionic cordova build ios --prod 离子cordova构建ios --prod

Note the --prod part which is key to tell the ionic CLI to create a production .APK with all the improvements that it involves, like cleaning css files, remove unused fonts, and some extra optimization processes. 请注意--prod部分,它是告诉离子CLI创建生产.APK的关键,它包含所涉及的所有改进,例如清理css文件,删除未使用的字体以及一些额外的优化过程。

You can change the "build" for "run" to install the app directly into your device or emulator. 您可以更改“运行”的“构建”,以将应用程序直接安装到您的设备或模拟器中。

Hope this helps! 希望这可以帮助! Best regards 最好的祝福

显然,您需要分析您的应用程序并查看它为何缓慢(如果它确实“慢”),但人们通常在加载应用程序时使用启动画面,以避免空白屏幕。

The blank screen comes because your Ionic app is in initial stage , i mean in build level. 空白屏幕是因为您的Ionic应用程序处于初始阶段,我的意思是在构建级别。 But when your produce this app then this blank screen never comes. 但是当你制作这个应用程序时,这个空白屏幕永远不会出现

ionic cordova build android --prod --release 离子cordova构建android --prod --release

Use above command and solve your problem. 使用上面的命令并解决您的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM