From f86bd8604392bd516fba5ad46f505f294ef28fab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20M=C3=A9tais?= Date: Sat, 20 Jun 2015 14:20:31 +0200 Subject: [PATCH] Add google analytics to already minified fies --- lib/tools/weightChecker/fileMinifier.js | 2 ++ test/core/fileMinifierTest.js | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/lib/tools/weightChecker/fileMinifier.js b/lib/tools/weightChecker/fileMinifier.js index 4f87476..d7b54a5 100644 --- a/lib/tools/weightChecker/fileMinifier.js +++ b/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); diff --git a/test/core/fileMinifierTest.js b/test/core/fileMinifierTest.js index 39d0f9c..90ce452 100644 --- a/test/core/fileMinifierTest.js +++ b/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); });