 core/core.libraries.yml                               | 12 ++++++------
 core/lib/Drupal/Core/Asset/JsCollectionOptimizer.php  |  8 +++++++-
 core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php |  1 +
 3 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/core/core.libraries.yml b/core/core.libraries.yml
index 71c923f..d88cb1e 100644
--- a/core/core.libraries.yml
+++ b/core/core.libraries.yml
@@ -21,7 +21,7 @@ classList:
     url: https://github.com/eligrey/classList.js/blob/master/LICENSE.md
     gpl-compatible: true
   js:
-    assets/vendor/classList/classList.min.js: { weight: -21, browsers: { IE: 'lte IE 9', '!IE': false } }
+    assets/vendor/classList/classList.min.js: { weight: -21, browsers: { IE: 'lte IE 9', '!IE': false }, optimized: true }
 
 ckeditor:
   remote: https://github.com/ckeditor/ckeditor-dev
@@ -31,7 +31,7 @@ ckeditor:
     url: https://github.com/ckeditor/ckeditor-dev/blob/887d81ac1824008b690e439a1b29eb4f13b51212/LICENSE.md
     gpl-compatible: true
   js:
-    assets/vendor/ckeditor/ckeditor.js: { preprocess: false }
+    assets/vendor/ckeditor/ckeditor.js: { preprocess: false, optimized: true }
 
 domready:
   remote: https://github.com/ded/domready
@@ -41,7 +41,7 @@ domready:
     url: https://github.com/ded/domready/blob/v1.0.6/LICENSE
     gpl-compatible: true
   js:
-    assets/vendor/domready/ready.min.js: { weight: -21 }
+    assets/vendor/domready/ready.min.js: { weight: -21, optimized: true }
 
 drupal:
   version: VERSION
@@ -299,7 +299,7 @@ html5shiv:
     url: http://www.gnu.org/licenses/gpl-2.0.html
     gpl-compatible: true
   js:
-    assets/vendor/html5shiv/html5.js: { every_page: true, weight: -22, browsers: { IE: 'lte IE 8', '!IE': false } }
+    assets/vendor/html5shiv/html5.js: { every_page: true, weight: -22, browsers: { IE: 'lte IE 8', '!IE': false }, optimized: true }
 
 jquery:
   remote: https://github.com/jquery/jquery
@@ -332,7 +332,7 @@ jquery.farbtastic:
     url: https://github.com/mattfarina/farbtastic/blob/master/LICENSE.txt
     gpl-compatible: true
   js:
-    assets/vendor/farbtastic/farbtastic.js: {}
+    assets/vendor/farbtastic/farbtastic.js: { optimized: true }
   css:
     component:
       assets/vendor/farbtastic/farbtastic.css: {}
@@ -761,7 +761,7 @@ modernizr:
     gpl-compatible: true
   version: v2.6.2
   js:
-    assets/vendor/modernizr/modernizr.min.js: { every_page: true, preprocess: 0, scope: header, weight: -21 }
+    assets/vendor/modernizr/modernizr.min.js: { every_page: true, preprocess: 0, scope: header, weight: -21, optimized: true }
 
 normalize:
   remote: https://github.com/necolas/normalize.css
diff --git a/core/lib/Drupal/Core/Asset/JsCollectionOptimizer.php b/core/lib/Drupal/Core/Asset/JsCollectionOptimizer.php
index 2356479..bd6566c 100644
--- a/core/lib/Drupal/Core/Asset/JsCollectionOptimizer.php
+++ b/core/lib/Drupal/Core/Asset/JsCollectionOptimizer.php
@@ -112,7 +112,13 @@ public function optimize(array $js_assets) {
               // Concatenate each asset within the group.
               $data = '';
               foreach ($js_group['items'] as $js_asset) {
-                $data .= $this->optimizer->optimize($js_asset);
+                // Optimize this JS file, but only if it's not yet optimized.
+                if ($js_asset['optimized']) {
+                  $data .= file_get_contents($js_asset['data']);
+                }
+                else {
+                  $data .= $this->optimizer->optimize($js_asset);
+                }
                 // Append a ';' and a newline after each JS file to prevent them
                 // from running together.
                 $data .= ";\n";
diff --git a/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php b/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php
index 3729161..4fa6313 100644
--- a/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php
+++ b/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php
@@ -135,6 +135,7 @@ public function buildByExtension($extension) {
           // processing order.
           if ($type == 'js') {
             $options['group'] = JS_LIBRARY;
+            $options['optimized'] = (isset($options['optimized']) ? $options['optimized'] : TRUE;
           }
           elseif ($type == 'css') {
             $options['group'] = $extension_type == 'theme' ? CSS_AGGREGATE_THEME : CSS_AGGREGATE_DEFAULT;
