-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adaptive site: disable non-critical tasks for users in the `adaptive-…
…site` test (#9024) Co-authored-by: Max Duval <max.duval@theguardian.com>
- Loading branch information
Showing
2 changed files
with
157 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,145 +1,152 @@ | ||
import './webpackPublicPath'; | ||
import { adaptSite, shouldAdapt } from './adaptiveSite'; | ||
import { startup } from './startup'; | ||
|
||
/************************************************************* | ||
* | ||
* The following modules are bundled in the entry chunk, | ||
* so they can be run immediately, but we still want to report | ||
* on the duration of loading and evaluating them. | ||
* | ||
*************************************************************/ | ||
void (async () => { | ||
if (await shouldAdapt()) { | ||
adaptSite(); | ||
} | ||
|
||
void startup( | ||
'bootCmp', | ||
() => | ||
import(/* webpackMode: "eager" */ './bootCmp').then(({ bootCmp }) => | ||
bootCmp(), | ||
), | ||
{ | ||
priority: 'critical', | ||
}, | ||
); | ||
/************************************************************* | ||
* | ||
* The following modules are bundled in the entry chunk, | ||
* so they can be run immediately, but we still want to report | ||
* on the duration of loading and evaluating them. | ||
* | ||
*************************************************************/ | ||
|
||
void startup( | ||
'recordInitialPageEvents', | ||
() => | ||
import( | ||
/* webpackMode: "eager" */ './ophan/recordInitialPageEvents' | ||
).then(({ recordInitialPageEvents }) => recordInitialPageEvents()), | ||
{ | ||
priority: 'critical', | ||
}, | ||
); | ||
void startup( | ||
'bootCmp', | ||
() => | ||
import(/* webpackMode: "eager" */ './bootCmp').then(({ bootCmp }) => | ||
bootCmp(), | ||
), | ||
{ | ||
priority: 'critical', | ||
}, | ||
); | ||
|
||
void startup( | ||
'ga', | ||
() => import(/* webpackMode: "eager" */ './ga').then(({ ga }) => ga()), | ||
{ | ||
priority: 'critical', | ||
}, | ||
); | ||
void startup( | ||
'recordInitialPageEvents', | ||
() => | ||
import( | ||
/* webpackMode: "eager" */ './ophan/recordInitialPageEvents' | ||
).then(({ recordInitialPageEvents }) => recordInitialPageEvents()), | ||
{ | ||
priority: 'critical', | ||
}, | ||
); | ||
|
||
void startup( | ||
'sentryLoader', | ||
() => | ||
import(/* webpackMode: "eager" */ './sentryLoader').then( | ||
({ sentryLoader }) => sentryLoader(), | ||
), | ||
{ | ||
priority: 'critical', | ||
}, | ||
); | ||
void startup( | ||
'ga', | ||
() => import(/* webpackMode: "eager" */ './ga').then(({ ga }) => ga()), | ||
{ | ||
priority: 'critical', | ||
}, | ||
); | ||
|
||
void startup( | ||
'dynamicImport', | ||
() => | ||
import(/* webpackMode: "eager" */ './dynamicImport').then( | ||
({ dynamicImport }) => dynamicImport(), | ||
), | ||
{ | ||
priority: 'critical', | ||
}, | ||
); | ||
void startup( | ||
'sentryLoader', | ||
() => | ||
import(/* webpackMode: "eager" */ './sentryLoader').then( | ||
({ sentryLoader }) => sentryLoader(), | ||
), | ||
{ | ||
priority: 'critical', | ||
}, | ||
); | ||
|
||
void startup( | ||
'islands', | ||
() => | ||
import(/* webpackMode: "eager" */ './islands').then(({ islands }) => | ||
islands(), | ||
), | ||
{ | ||
priority: 'critical', | ||
}, | ||
); | ||
void startup( | ||
'dynamicImport', | ||
() => | ||
import(/* webpackMode: "eager" */ './dynamicImport').then( | ||
({ dynamicImport }) => dynamicImport(), | ||
), | ||
{ | ||
priority: 'critical', | ||
}, | ||
); | ||
|
||
void startup( | ||
'poorPerformanceMonitoring', | ||
() => | ||
import(/* webpackMode: "eager" */ './poorPerformanceMonitoring').then( | ||
({ recordPoorPerformance }) => recordPoorPerformance(), | ||
), | ||
{ | ||
priority: 'critical', | ||
}, | ||
); | ||
void startup( | ||
'islands', | ||
() => | ||
import(/* webpackMode: "eager" */ './islands').then(({ islands }) => | ||
islands(), | ||
), | ||
{ | ||
priority: 'critical', | ||
}, | ||
); | ||
|
||
/************************************************************* | ||
* | ||
* The following modules are lazy loaded, | ||
* because they are lower priority and do not want to block | ||
* the modules above on loading these. | ||
* | ||
* We are not assigning chunk name to allow Webpack | ||
* to optimise chunking based on its algorithm. | ||
* | ||
*************************************************************/ | ||
void startup( | ||
'poorPerformanceMonitoring', | ||
() => | ||
import( | ||
/* webpackMode: "eager" */ './poorPerformanceMonitoring' | ||
).then(({ recordPoorPerformance }) => recordPoorPerformance()), | ||
{ | ||
priority: 'critical', | ||
}, | ||
); | ||
|
||
void startup( | ||
'atomIframe', | ||
() => | ||
import( | ||
/* webpackMode: 'lazy' */ | ||
'./atomIframe' | ||
).then(({ atomIframe }) => atomIframe()), | ||
{ priority: 'feature' }, | ||
); | ||
/************************************************************* | ||
* | ||
* The following modules are lazy loaded, | ||
* because they are lower priority and do not want to block | ||
* the modules above on loading these. | ||
* | ||
* We are not assigning chunk name to allow Webpack | ||
* to optimise chunking based on its algorithm. | ||
* | ||
*************************************************************/ | ||
|
||
void startup( | ||
'embedIframe', | ||
() => | ||
import( | ||
/* webpackMode: 'lazy' */ | ||
'./embedIframe' | ||
).then(({ embedIframe }) => embedIframe()), | ||
{ priority: 'feature' }, | ||
); | ||
void startup( | ||
'atomIframe', | ||
() => | ||
import( | ||
/* webpackMode: 'lazy' */ | ||
'./atomIframe' | ||
).then(({ atomIframe }) => atomIframe()), | ||
{ priority: 'feature' }, | ||
); | ||
|
||
void startup( | ||
'newsletterEmbedIframe', | ||
() => | ||
import( | ||
/* webpackMode: 'lazy' */ | ||
'./newsletterEmbedIframe' | ||
).then(({ newsletterEmbedIframe }) => newsletterEmbedIframe()), | ||
{ priority: 'feature' }, | ||
); | ||
void startup( | ||
'embedIframe', | ||
() => | ||
import( | ||
/* webpackMode: 'lazy' */ | ||
'./embedIframe' | ||
).then(({ embedIframe }) => embedIframe()), | ||
{ priority: 'feature' }, | ||
); | ||
|
||
void startup( | ||
'relativeTime', | ||
() => | ||
import( | ||
/* webpackMode: 'lazy' */ | ||
'./relativeTime' | ||
).then(({ relativeTime }) => relativeTime()), | ||
{ priority: 'feature' }, | ||
); | ||
void startup( | ||
'newsletterEmbedIframe', | ||
() => | ||
import( | ||
/* webpackMode: 'lazy' */ | ||
'./newsletterEmbedIframe' | ||
).then(({ newsletterEmbedIframe }) => newsletterEmbedIframe()), | ||
{ priority: 'feature' }, | ||
); | ||
|
||
void startup( | ||
'initDiscussion', | ||
() => | ||
import( | ||
/* webpackMode: 'lazy' */ | ||
'./discussion' | ||
).then(({ discussion }) => discussion()), | ||
{ priority: 'feature' }, | ||
); | ||
void startup( | ||
'relativeTime', | ||
() => | ||
import( | ||
/* webpackMode: 'lazy' */ | ||
'./relativeTime' | ||
).then(({ relativeTime }) => relativeTime()), | ||
{ priority: 'feature' }, | ||
); | ||
|
||
void startup( | ||
'initDiscussion', | ||
() => | ||
import( | ||
/* webpackMode: 'lazy' */ | ||
'./discussion' | ||
).then(({ discussion }) => discussion()), | ||
{ priority: 'feature' }, | ||
); | ||
})(); |