Skip to content

Commit

Permalink
detect link server side rendering for amp-story-1.0.css (#37182)
Browse files Browse the repository at this point in the history
  • Loading branch information
erwinmombay committed Dec 13, 2021
1 parent 5dc7237 commit 20cb5f7
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions extensions/amp-story/1.0/amp-story.js
Original file line number Diff line number Diff line change
Expand Up @@ -424,16 +424,24 @@ export class AmpStory extends AMP.BaseElement {
'story-disable-animations-first-page'
);
}
// [i-amphtml-version] marks that the style was inlined in the doc server-side.
if (
this.getAmpDoc()
.getRootNode()
.documentElement.querySelector(
'style[amp-extension="amp-story"][i-amphtml-version]'
)
) {
const docElem = this.getAmpDoc().getRootNode().documentElement;
// [i-amphtml-version] marks that the style was inlined in the doc
// server-side.
const inlinedAmpStoryCssExists = docElem.querySelector(
'style[amp-extension="amp-story"][i-amphtml-version]'
);
// [amp-extension=amp-story] on a stylesheet link marks that the style
// was linked on the doc server-side.
const linkAmpStoryCssExists = docElem.querySelector(
'link[amp-extension="amp-story"][rel=stylesheet]'
);

if (inlinedAmpStoryCssExists) {
performanceService.addEnabledExperiment('story-inline-css');
} else if (linkAmpStoryCssExists) {
performanceService.addEnabledExperiment('story-link-css');
}

if (isExperimentOn(this.win, 'story-load-inactive-outside-viewport')) {
performanceService.addEnabledExperiment(
'story-load-inactive-outside-viewport'
Expand Down

0 comments on commit 20cb5f7

Please sign in to comment.