2017-03-30 34 views
1

我对前端开发很有新意,并且在使用angular2应用时遇到了一些问题。角2填充初始化需要太长时间

正如你可以看到下面的时间表捕获,polyfills TAKS太长的时间(将近6秒!) chrome timeline 这似乎不是一个正常的。但是,我不知道我能做些什么来减少这个填充时间。

conf的一些行。

// Add build specific plugins 
    if (ENV === 'build') { 
    config.plugins.push(
     // Reference: http://webpack.github.io/docs/list-of-plugins.html#noerrorsplugin 
     // Only emit files when there are no errors 
     new webpack.NoErrorsPlugin(), 

     // Reference: http://webpack.github.io/docs/list-of-plugins.html#dedupeplugin 
     // Dedupe modules in the output 
     new webpack.optimize.DedupePlugin(), 

     // Reference: http://webpack.github.io/docs/list-of-plugins.html#uglifyjsplugin 
     // Minify all javascript, switch loaders to minimizing mode 
     new webpack.optimize.UglifyJsPlugin({ 
      compress: { warnings: false } 
     }) 
    ); 
    } 

整个webpack.config.js我在我的应用程序中使用。 https://gist.github.com/jeesim2/484186d630fedc9f42e264ca905ad123

我的角度版本

"@angular/common": "^2.0.1", 
"@angular/compiler": "^2.0.1", 
"@angular/core": "^2.0.1", 
"@angular/forms": "^2.0.1", 
"@angular/http": "^2.0.1", 
"@angular/platform-browser": "^2.0.1", 
"@angular/platform-browser-dynamic": "^2.0.1", 
"@angular/router": "^3.0.1", 

webpack.optimize.UglifyJsPlugin封装尺寸减少到70%,但页面加载速度并没有得到更快。 enter image description here

什么导致这种长页面加载?

回答

0

欢迎来到angular2单页应用:)。 A2仍然处于开发状态。这种行为是正常的,取决于OS /浏览器/组件编号渲染需要几秒钟。由于A2/vendors/polyfills的捆绑文件大约为800kb +(最小化),因此需要一些时间才能将所有内容全部读取到浏览器内存中。

您可以检查渲染速度是否相当快,但脚本可以在初始化后的几秒钟内在后台运行。即使在快速PC上也需要一些时间。

这是由https://github.com/angular/zone.js/