Skip to content

Commit

Permalink
♻️ [Story performance] Extract performance service into variable (#37137
Browse files Browse the repository at this point in the history
)

* Add isTransformed

* Added isTransformed to report

* Added stories transformed

* Removed story-

* Added inline css CSI

* Added comment

* Updated comment

* Simplify performance service getter
  • Loading branch information
mszylkowski committed Dec 7, 2021
1 parent 1c2b7ff commit 4b8df10
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions extensions/amp-story/1.0/amp-story.js
Original file line number Diff line number Diff line change
Expand Up @@ -410,18 +410,17 @@ export class AmpStory extends AMP.BaseElement {
this.switchTo_(args['id'], NavigationDirection.NEXT);
});
}
const performanceService = Services.performanceFor(this.win);
if (isExperimentOn(this.win, 'story-load-first-page-only')) {
Services.performanceFor(this.win).addEnabledExperiment(
'story-load-first-page-only'
);
performanceService.addEnabledExperiment('story-load-first-page-only');
}
if (
isExperimentOn(this.win, 'story-disable-animations-first-page') ||
isPreviewMode(this.win) ||
prefersReducedMotion(this.win) ||
isTransformed(this.getAmpDoc())
) {
Services.performanceFor(this.win).addEnabledExperiment(
performanceService.addEnabledExperiment(
'story-disable-animations-first-page'
);
}
Expand All @@ -433,12 +432,10 @@ export class AmpStory extends AMP.BaseElement {
'style[amp-extension="amp-story"][i-amphtml-version]'
)
) {
Services.performanceFor(this.win).addEnabledExperiment(
'story-inline-css'
);
performanceService.addEnabledExperiment('story-inline-css');
}
if (isExperimentOn(this.win, 'story-load-inactive-outside-viewport')) {
Services.performanceFor(this.win).addEnabledExperiment(
performanceService.addEnabledExperiment(
'story-load-inactive-outside-viewport'
);
this.element.classList.add(
Expand Down

0 comments on commit 4b8df10

Please sign in to comment.