gpt4 book ai didi

javascript - 使用 System.js 的性能问题

转载 作者:可可西里 更新时间:2023-11-01 02:12:48 31 4
gpt4 key购买 nike

我正在玩弄 system.js(受 angular2 的启发,在他们的教程中使用它),但即使对于最微不足道的示例,我的性能也差得离谱。

例如,以下代码在第二个(System.import 之前的那个)和最后一个(在 app.js 中)控制台之间有 26000ms(!) 的延迟.log 在本地运行时(因此没有网络延迟)

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>

应用程序.js:

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

我通过 bower ("system.js": "~0.18.17") 安装了最新的 system.js 版本并删除了所有剩余的代码,它实际上只是需要很长时间的 System.import 调用。那我做错了什么?

在 Chrome 下加载页面时网络选项卡的图片: enter image description here

最佳答案

考虑到 system.js 异步加载脚本,26 毫秒是脚本的正常加载速度。您的本地服务器需要一些时间来处理请求/响应作业​​,并为此造成一些延迟。

关于javascript - 使用 System.js 的性能问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32618413/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com