Skip to content

Commit 357016c

Browse files
patrickhulcebrendankenny
authored andcommitted
fix: blocking link async and time ms bugs (#963)
1 parent f04f1c8 commit 357016c

5 files changed

Lines changed: 41 additions & 3 deletions

File tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<!--
2+
* Copyright 2016 Google Inc. All rights reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
-->
16+
<div>
17+
Blocking content
18+
</div>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<!--
2+
* Copyright 2016 Google Inc. All rights reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
-->
16+
<div>
17+
Async content
18+
</div>

lighthouse-cli/test/fixtures/dobetterweb/dbw_tester.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
<template id="links-blocking-first-paint-tmpl">
2828
<link rel="stylesheet" href="./dbw_tester.css">
2929
<link rel="stylesheet" href="./dbw_disabled.css" disabled>
30+
<link rel="import" href="./dbw_partial_a.html">
31+
<link rel="import" href="./dbw_partial_b.html" async>
3032
</template>
3133

3234
<style>

lighthouse-core/gather/gatherers/dobetterweb/links-blocking-first-paint.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function collectLinksThatBlockFirstPaint() {
3131
// https://www.w3.org/TR/html-imports/#dfn-import-async-attribute
3232
const blockingStylesheet = (link.rel === 'stylesheet' &&
3333
window.matchMedia(link.media).matches && !link.disabled);
34-
const blockingImport = link.rel === 'import' && link.hasAttribute('async');
34+
const blockingImport = link.rel === 'import' && !link.hasAttribute('async');
3535
return blockingStylesheet || blockingImport;
3636
})
3737
.map(link => {
@@ -66,7 +66,7 @@ class LinksBlockingFirstPaint extends Gatherer {
6666
}
6767

6868
_formatMS(info) {
69-
return Math.round((info.endTime - info.startTime) * 100) / 100;
69+
return Math.round((info.endTime - info.startTime) * 1000);
7070
}
7171

7272
afterPass(options, tracingData) {

lighthouse-core/test/gather/gatherers/dobetterweb/links-blocking-first-paint-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ describe('First paint blocking links', () => {
5757
return assert.equal(linksBlockingFirstPaint._formatMS({
5858
startTime: 0.888,
5959
endTime: 0.999
60-
}), 0.11);
60+
}), 111);
6161
});
6262

6363
it('return filtered link', () => {

0 commit comments

Comments
 (0)