Browse Source

Add google analytics to already minified fies

Gaël Métais 10 years ago
parent
commit
f86bd86043
2 changed files with 7 additions and 0 deletions
  1. 2 0
      lib/tools/weightChecker/fileMinifier.js
  2. 5 0
      test/core/fileMinifierTest.js

+ 2 - 0
lib/tools/weightChecker/fileMinifier.js

@@ -301,6 +301,8 @@ var FileMinifier = function() {
         // jQuery CDN
         result = result || /^https?:\/\/code\.jquery\.com\/.*\.min.js/.test(url);
 
+        // Google Analytics
+        result = result || /^https?:\/\/(www|ssl)\.google-analytics\.com\/(.*)\.js/.test(url);
 
         if (result === true) {
             debug('This file is known as already minified. Skipping minification: %s', url);

+ 5 - 0
test/core/fileMinifierTest.js

@@ -233,6 +233,11 @@ describe('fileMinifier', function() {
         fileMinifier.isKnownAsMinified('https://code.jquery.com/jquery-2.1.4.js').should.equal(false);
         fileMinifier.isKnownAsMinified('http://code.jquery.com/jquery-2.1.4.js').should.equal(false);
 
+        fileMinifier.isKnownAsMinified('https://ssl.google-analytics.com/ga.js').should.equal(true);
+        fileMinifier.isKnownAsMinified('http://www.google-analytics.com/ga.js').should.equal(true);
+        fileMinifier.isKnownAsMinified('https://www.google-analytics.com/analytics.js').should.equal(true);
+        fileMinifier.isKnownAsMinified('http://www.google-analytics.com/analytics.js').should.equal(true);
+
         fileMinifier.isKnownAsMinified('http://anydomain.com/anyurl').should.equal(false);
     });