为什么Aurelia的Alpha版本加载缓慢? [英] Why does the alpha version of Aurelia load slowly?
问题描述
我写了一个最小的测试页面来试用Aurelia.
I wrote a minimal test page to try out Aurelia.
http://www.andrewgolightly.com/
GitHub: https://github.com/magician11/ag-landingpage
我的上一个测试显示,加载135个请求页面需要55秒.
My last test, showed it took 55 seconds to load the page with 135 requests.
似乎我需要先捆绑jspm_packages目录,以便一次下载543KB..而不是分段下载.
It seems I need to bundle the jspm_packages directory first so that the 543KB gets downloaded at once.. and not in pieces.
因此,我遵循以下示例: http://aurelia.io/get-started.html
So given I followed this example: http://aurelia.io/get-started.html
如何捆绑软件包?从 https://github.com/jspm/jspm-cli/wiki/Production-工作流程
然后在index.html文件中更新什么?而且我仍然需要在头中引用jspm_packages文件夹,对吧?
And then what do I update in my index.html file? And I'll still need to include the jspm_packages folder as I reference it in the head, right?
<link rel="stylesheet" href="jspm_packages/github/twbs/bootstrap@3.3.2/css/bootstrap.min.css">
<link rel="stylesheet" href="jspm_packages/npm/font-awesome@4.3.0/css/font-awesome.min.css">
谢谢.
更新
团队正在努力进行捆绑..
The team is working on bundling..
来自罗布·艾森伯格(Rob Eisenberg):我们还没有提供捆绑支持.我们正在努力."
From Rob Eisenberg: "We aren’t finished with our bundling support just yet. We’re working on it."
推荐答案
这个问题是在非常的早期发布的,但是我们现在有一个可以与jspm和system.js一起使用的策略捆绑式装载机.需要注意的是,并不是说框架很慢,而是因为大量请求(而且您可能未启用gzip)导致资产加载花了很早的时间.
This question was posted at a very early time but we do have a strategy now in place that works with jspm and system.js loader for bundling. As a note it's not that the framework is slow it's that the loading of assets was taking a while early on due to the high number of requests (and that you probably didn't have gzip enabled)
我已经从我的博客文章中复制了此内容- http://patrickwalters.net/my-best-practices-aurelia捆绑和缩小/
I've copied this from my blog post on the subject - http://patrickwalters.net/my-best-practices-for-aurelia-bundling-and-minification/
Understand that a jspm bundle command is used to let system.js, our module loader, know to load the bundle
了解这仅涵盖JavaScript文件(目前)
Understand this only covers the JavaScript files (for now)
创建一个新的捆绑包
- 打开您的终端并导航到您的
skeleton-navigation
文件夹. - 在文本编辑器中打开config.js
-
运行此命令-
- Open your terminal and navigate to your
skeleton-navigation
folder. - Open your config.js in your text editor
Run this command -
jspm bundle '*' + aurelia-skeleton-navigation/* + aurelia-bootstrapper + aurelia-http-client + aurelia-dependency-injection + aurelia-router dist/app-bundle.js --inject --minify
故障
// Create a bundle
jspm bundle
// Bundle all of these paths
// from my config.js
'*' +
aurelia-skeleton-navigation/* +
aurelia-bootstrapper +
aurelia-http-client +
aurelia-dependency-injection +
aurelia-router
// Create the bundle here
// with this name
dist/app-bundle.js
// These modifiers tell the bundle
// to both minify and then inject
// the bundle
--inject
--minify
关于捆绑的其他说明
- 如果您正在生产中,则可能需要查看 config.js中的设置
baseUrl
. 这样 - 要单独打包和提供文件,请使用
jspm unbundle
- 由于我们使用了
--inject
修饰符,因此system.js应该在捆绑包中拾取并提供服务,而无需更改index.html中的脚本路径 - 您可以使用捆绑包区域中的
+ {filename}
添加更多文件
- If you are serving in production you may want to look at setting
baseUrl
in your config.js like that - To unbundle and serve files individually use
jspm unbundle
- Since we used the
--inject
modifier system.js should pick up on our bundle and serve it without changing our script path in index.html - You can add more files by using
+ {filename}
in the bundle area
这篇关于为什么Aurelia的Alpha版本加载缓慢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!