Skip to content

Commit

Permalink
Experimental: force style recalc before making body visible (#33374)
Browse files Browse the repository at this point in the history
* Force style recalc before making body visible

* lints
  • Loading branch information
Dima Voytenko committed Mar 19, 2021
1 parent ffa7e32 commit a190819
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/style-installer.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,12 @@ export function makeBodyVisible(doc) {
})
.then((services) => {
bodyMadeVisible = true;
if (INI_LOAD_INOB) {
// Force sync measurement to ensure that style recalc is complete
// before showing body, which would trigger FCP. This should reduce
// make it less likely that a CLS would be triggered after FCP.
doc.body./*OK*/ getBoundingClientRect();
}
setBodyVisibleStyles(doc);
const ampdoc = getAmpdoc(doc);
ampdoc.signals().signal(CommonSignals.RENDER_START);
Expand Down

0 comments on commit a190819

Please sign in to comment.