mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-03 19:32:35 +02:00
perf(v2): reduce main bundle size by using es5 if possible (#1979)
This commit is contained in:
parent
245b50f6e0
commit
8242c0eb00
2 changed files with 3 additions and 4 deletions
|
@ -63,7 +63,7 @@ class PendingNavigation extends React.Component {
|
||||||
if (!hash) {
|
if (!hash) {
|
||||||
window.scrollTo(0, 0);
|
window.scrollTo(0, 0);
|
||||||
} else {
|
} else {
|
||||||
const id = hash.replace('#', '');
|
const id = hash.substring(1);
|
||||||
const element = document.getElementById(id);
|
const element = document.getElementById(id);
|
||||||
if (element) element.scrollIntoView();
|
if (element) element.scrollIntoView();
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ const isSlowConnection = () => {
|
||||||
// if user is on slow or constrained connection
|
// if user is on slow or constrained connection
|
||||||
if (`connection` in navigator) {
|
if (`connection` in navigator) {
|
||||||
if (
|
if (
|
||||||
(navigator.connection.effectiveType || ``).includes(`2g`) &&
|
(navigator.connection.effectiveType || ``).indexOf(`2g`) !== -1 &&
|
||||||
navigator.connection.saveData
|
navigator.connection.saveData
|
||||||
) {
|
) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -55,8 +55,7 @@ const docusaurus = {
|
||||||
const chunkAssets = window.__chunkMapping[chunkName] || [];
|
const chunkAssets = window.__chunkMapping[chunkName] || [];
|
||||||
return arr.concat(chunkAssets);
|
return arr.concat(chunkAssets);
|
||||||
}, []);
|
}, []);
|
||||||
const dedupedChunkAssets = Array.from(new Set(chunkAssetsNeeded));
|
Promise.all(chunkAssetsNeeded.map(prefetchHelper)).then(() => {
|
||||||
Promise.all(dedupedChunkAssets.map(prefetchHelper)).then(() => {
|
|
||||||
fetched[routePath] = true;
|
fetched[routePath] = true;
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue