简体   繁体   English

使用System.js的性能问题

[英]Performance Problems using System.js

I'm playing around with system.js (inspired by angular2 using it for their tutorials), but I get ridiculously bad performance even for the most trivial sample. 我正在玩system.js(灵感来自angular2使用它作为他们的教程),但即使对于最琐碎的样本,我的表现仍然糟糕。

For example the following code has a delay of 26000ms(!) between the second (the one before System.import ) and last (in app.js ) console.log while running locally (so no network delay) 例如,以下代码在第二个( System.import之前)和最后一个(在app.js )console.log之间的延迟为26000ms(!),同时在本地运行(因此没有网络延迟)

index.html: index.html的:

<!DOCTYPE html>
<html lang="en">
<head>
    <title>System.js Sample</title>
    <script>console.log("1: " + new Date().getTime());</script>
    <script src="bower_components/system.js/dist/system.js"></script>
</head>
<body>
<script>
    console.log('2: ' + new Date().getTime());
    System.import('app.js');
</script>
</body>
</html>

App.js: App.js:

console.log('3: ' + new Date().getTime());

I installed the newest system.js version via bower ("system.js": "~0.18.17") and removed all the remaining code it's really just the System.import call that takes ages. 我通过bower(“system.js”:“~0.18.17”)安装了最新的system.js版本并删除了所有剩余的代码,它实际上只是需要很长时间的System.import调用。 So what am I doing wrong? 那么我做错了什么?

Picture of the Network tab when loading the page under Chrome: 在Chrome下加载页面时,“网络”标签的图片: 在此输入图像描述

Having in mind that system.js loads scripts asynchronously, 26ms is a normal load speed of your script. 考虑到system.js异步加载脚本,26ms是脚本的正常加载速度。 Your local server needs some time to process the request/response job and causes some delay for this. 您的本地服务器需要一些时间来处理请求/响应作业​​并导致一些延迟。

The initial Angular2 quickstart repo would load RxJS files individually which took too long. 最初的Angular2快速入门仓库将单独加载RxJS文件,这花费的时间太长。 You would often find 300+ requests being made. 您经常会发现300多个请求。 Since then they have fixed this and you can further reduce requests made by being specific when you import RxJS modules. 从那时起,他们已经修复了这个问题,您可以进一步减少导入RxJS模块时特定的请求。 Angular quickstart repo is much quicker these days. 如今,Angular快速启动回购更加快捷。

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

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