2017-01-10 8 views
1

クロスオリジンリソースの共有を有効にすると、アプリケーションの読み込みに8〜9秒かかります。そのディスエーブルに1-2秒かかるとき。私はこれで本当に新しいです。どのようなアイデアが主要な問題になるのでしょうか?そしてそれをスピードアップする方法は?このアプリケーションは、実際にデータを要求していないため、実際にはかなり早い段階にあり、8秒という非常に長い時間です。ここで角2の低速初期ロード

は、私はそれを解決し、私のindex.htmlは

<!DOCTYPE html> 
<html> 

    <head> 
    <script src="https://unpkg.com/[email protected]/dist/zone.js"></script> 
    <script src="https://unpkg.com/[email protected]/Reflect.js"></script> 
    <script src="https://unpkg.com/[email protected]/dist/system.js"></script> 
    <script src="config.js"></script> 
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> 
     <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"> 
      <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> 


    <script> 
    System.import('app/js/bootstrap') 
     .catch(console.error.bind(console)); 
    </script> 
    <script src="app/js/xml2json.js"></script> 
    <script src="app/js/div.js"></script> 
     <script src="app/js/divY.js"></script> 

    <style> 
    body,html{width:100%;height:100%;padding:5px;margin:0;} 

    </style> 
    <script src="https://code.jquery.com/jquery-1.12.4.js"></script> 
<script src="//cdn.jsdelivr.net/interact.js/1.2.6/interact.min.js"></script> 
    </head> 


    <body> 
    <app> 
    loading... 
    </app> 
    </body> 

</html> 

されており、ここで私のconfig.jsの

System.config({ 
    //use typescript for compilation 
    transpiler: 'typescript', 
    //typescript compiler options 
    typescriptOptions: { 
    emitDecoratorMetadata: true 
    }, 
    paths: { 
    'npm:': 'https://unpkg.com/' 
    }, 
    //map tells the System loader where to look for things 
    map: { 
    'app': "./app", 
    'ng2-translate': 'npm:ng2-translate', 
    '@angular/core': 'npm:@angular/core/bundles/core.umd.js', 
    '@angular/common': 'npm:@angular/common/bundles/common.umd.js', 
    '@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js', 
    '@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js', 
    '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js', 
    '@angular/http': 'npm:@angular/http/bundles/http.umd.js', 
    '@angular/router': 'npm:@angular/router/bundles/router.umd.js', 
    '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js', 

    '@angular/core/testing': 'npm:@angular/core/bundles/core-testing.umd.js', 
    '@angular/common/testing': 'npm:@angular/common/bundles/common-testing.umd.js', 
    '@angular/compiler/testing': 'npm:@angular/compiler/bundles/compiler-testing.umd.js', 
    '@angular/platform-browser/testing': 'npm:@angular/platform-browser/bundles/platform-browser-testing.umd.js', 
    '@angular/platform-browser-dynamic/testing': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic-testing.umd.js', 
    '@angular/http/testing': 'npm:@angular/http/bundles/http-testing.umd.js', 
    '@angular/router/testing': 'npm:@angular/router/bundles/router-testing.umd.js', 

    'rxjs': 'npm:rxjs', 
    'typescript': 'npm:[email protected]/lib/typescript.js' 
    }, 
    //packages defines our app package 
    packages: { 
    app: { 
     main: './bootstrap.ts', 
     defaultExtension: 'js' 
    }, 
    rxjs: { 
     defaultExtension: 'js' 
    }, 
    'ng2-translate': { 
     defaultExtension: 'js' 
    } 
    } 


}); 
+0

フォルダーとルートを確認してください。あなたはapp/jsに保存していますか? (アプリケーション) –

+0

あなたはrxjsライブラリ全体をインポートしていますか?rxjsのすべてのクラスが必要ですか? –

+0

は多くの助けとなりました。今、私はzone.jsから多くのreqを見ています。 – emar

答えて

0

です。ここに作業ファイルがあります。マップからrxjsを削除してパスに追加しました

System.config({ 
    //use typescript for compilation 
    transpiler: 'typescript', 
    //typescript compiler options 
    typescriptOptions: { 
    emitDecoratorMetadata: true 
    }, 
    paths: { 
    'npm:': 'https://unpkg.com/', 
    'rxjs*': 'https://unpkg.com/@reactivex/[email protected]/dist/global/Rx.js' 
    }, 
    //map tells the System loader where to look for things 
    map: { 
    'app': "./app", 
    'ng2-translate': 'npm:ng2-translate', 
    '@angular/core': 'npm:@angular/core/bundles/core.umd.js', 
    '@angular/common': 'npm:@angular/common/bundles/common.umd.js', 
    '@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js', 
    '@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js', 
    '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js', 
    '@angular/http': 'npm:@angular/http/bundles/http.umd.js', 
    '@angular/router': 'npm:@angular/router/bundles/router.umd.js', 
    '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js', 

    '@angular/core/testing': 'npm:@angular/core/bundles/core-testing.umd.js', 
    '@angular/common/testing': 'npm:@angular/common/bundles/common-testing.umd.js', 
    '@angular/compiler/testing': 'npm:@angular/compiler/bundles/compiler-testing.umd.js', 
    '@angular/platform-browser/testing': 'npm:@angular/platform-browser/bundles/platform-browser-testing.umd.js', 
    '@angular/platform-browser-dynamic/testing': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic-testing.umd.js', 
    '@angular/http/testing': 'npm:@angular/http/bundles/http-testing.umd.js', 
    '@angular/router/testing': 'npm:@angular/router/bundles/router-testing.umd.js', 

    // 'rxjs': 'https://unpkg.com/[email protected]', 
    'typescript': 'npm:[email protected]/lib/typescript.js' 
    }, 
    //packages defines our app package 
    packages: { 
    app: { 
     main: './bootstrap.ts', 
     defaultExtension: 'js' 
    }, 
    rxjs: { 
     defaultExtension: 'js' 
    }, 
    'ng2-translate': { 
     defaultExtension: 'js' 
    } 
    } 


}); 
関連する問題