[英]Site loading issue: Angular 6 project taking too much time to load
In the above picture its clear that My application is taking too much time(3 mins as shown in the image) to load for the first time. 在上图中,很明显,我的应用程序花费了太多时间(如图中的3分钟)来首次加载。 I am not able to find the actual reason. 我找不到实际原因。
Some details about my application: 有关我的应用程序的一些细节:
If any further details is needed I ll provide , Please help me out in finding the actual reason behind the delay. 如果需要其他详细信息,请帮我找出延迟原因。
Take the advantage of angular router and module lazy loading. 利用角度路由器和模块延迟加载的优势。 For example create module of relevant component and when the vie is visited load the specific js file 例如,创建相关组件的模块,并在访问vie时加载特定的js文件
In the example when customer
route is visited it will load the relevant js file so is other module 在示例中,当访问customer
路线时,它将加载相关的js文件,其他模块也会加载
const routes: Routes = [
{
path: 'customers',
loadChildren: './customers/customers.module#CustomersModule'
},
{
path: 'orders',
loadChildren: './orders/orders.module#OrdersModule'
}
];
Also you can run ng build --prod
. 您也可以运行ng build --prod
。 This will compress the code, will eliminate dead code 这将压缩代码,将消除无效代码
It can be 13 components with 6K lines of code. 它可以是13个具有6K行代码的组件。 Number of components don't matter, code complexity does. 组件数量无关紧要,代码复杂度却无关紧要。
Lazy loading doesn't reduce the bundle size : lazy loading is the features that loads the Javascript when asked instead of when received 延迟加载不会减小包的大小:延迟加载是在询问时而不是在收到 时加载Javascript的功能
spec
files don't appear in the build, and .scss
files are compiled into JS (making no difference in the final build, whether you use inline styling or URL styling) spec
文件没有出现在构建中,并且.scss
文件被编译到JS中(无论您使用内联样式还是URL样式,最终版本都没有影响)
See point n° 1 见第1点
Again, similar to point n° 1, it depends on the commands you run and the code you need to compile. 再次,类似于点n°1,它取决于您运行的命令和需要编译的代码。
I can't see images, but have you ran a lighthouse audit on your application ? 我看不到图像,但是您是否对应用程序进行了灯塔审核 ? It might tell you what you can improve. 它可能会告诉您可以改进的地方。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.