Skip to content

Commit

Permalink
Remove images from critical request chains. (#2085)
Browse files Browse the repository at this point in the history
  • Loading branch information
abacon authored and paulirish committed May 9, 2017
1 parent d0cb646 commit b5bf067
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ module.exports = [
displayValue: '0'
},
'critical-request-chains': {
score: false,
displayValue: '1'
score: true,
displayValue: '0'
},
'webapp-install-banner': {
score: false
Expand Down
4 changes: 4 additions & 0 deletions lighthouse-core/gather/computed/critical-request-chains.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ class CriticalRequestChains extends ComputedArtifact {
if (resourceTypeCategory === WebInspector.resourceTypes.XHR._category) {
return false;
}
// Images are also non-critical.
if (resourceTypeCategory === WebInspector.resourceTypes.Image._category) {
return false;
}

// Treat favicons as non-critical resources
if (request.mimeType === 'image/x-icon' ||
Expand Down
49 changes: 19 additions & 30 deletions lighthouse-core/test/audits/critical-request-chains-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,30 +50,6 @@ const FAILING_REQUEST_CHAIN = {
}
};

const FAILING_REQUEST_CHAIN_2 = {
13653.1: {
request: {
url: 'http://localhost:10503/offline-ready.html',
startTime: 33552.036878,
endTime: 33552.285438,
responseReceivedTime: 33552.275677,
transferSize: 1849
},
children: {
13653.2: {
request: {
url: 'http://localhost:10503/icon-128.png?delay',
startTime: 33552.318928,
endTime: 33554.33721,
responseReceivedTime: 33554.334569,
transferSize: 99
},
children: {}
}
}
}
};

const PASSING_REQUEST_CHAIN = {
0: {
request: {
Expand All @@ -86,6 +62,19 @@ const PASSING_REQUEST_CHAIN = {
},
};

const PASSING_REQUEST_CHAIN_2 = {
13653.1: {
request: {
url: 'http://localhost:10503/offline-ready.html',
startTime: 33552.036878,
endTime: 33552.285438,
responseReceivedTime: 33552.275677,
transferSize: 1849
},
children: {}
}
};

const EMPTY_REQUEST_CHAIN = {};

const mockArtifacts = (mockChain) => {
Expand All @@ -111,15 +100,15 @@ describe('Performance: critical-request-chains audit', () => {
});
});

it('calculates the correct chain result for failing example (no 2.)', () => {
return Audit.audit(mockArtifacts(FAILING_REQUEST_CHAIN_2)).then(output => {
assert.equal(output.displayValue, 1);
assert.equal(output.rawValue, false);
it('calculates the correct chain result for passing example', () => {
return Audit.audit(mockArtifacts(PASSING_REQUEST_CHAIN)).then(output => {
assert.equal(output.displayValue, 0);
assert.equal(output.rawValue, true);
});
});

it('calculates the correct chain result for passing example', () => {
return Audit.audit(mockArtifacts(PASSING_REQUEST_CHAIN)).then(output => {
it('calculates the correct chain result for passing example (no 2.)', () => {
return Audit.audit(mockArtifacts(PASSING_REQUEST_CHAIN_2)).then(output => {
assert.equal(output.displayValue, 0);
assert.equal(output.rawValue, true);
});
Expand Down

0 comments on commit b5bf067

Please sign in to comment.