mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-02 02:42:41 +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) {
|
||||
window.scrollTo(0, 0);
|
||||
} else {
|
||||
const id = hash.replace('#', '');
|
||||
const id = hash.substring(1);
|
||||
const element = document.getElementById(id);
|
||||
if (element) element.scrollIntoView();
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ const isSlowConnection = () => {
|
|||
// if user is on slow or constrained connection
|
||||
if (`connection` in navigator) {
|
||||
if (
|
||||
(navigator.connection.effectiveType || ``).includes(`2g`) &&
|
||||
(navigator.connection.effectiveType || ``).indexOf(`2g`) !== -1 &&
|
||||
navigator.connection.saveData
|
||||
) {
|
||||
return true;
|
||||
|
@ -55,8 +55,7 @@ const docusaurus = {
|
|||
const chunkAssets = window.__chunkMapping[chunkName] || [];
|
||||
return arr.concat(chunkAssets);
|
||||
}, []);
|
||||
const dedupedChunkAssets = Array.from(new Set(chunkAssetsNeeded));
|
||||
Promise.all(dedupedChunkAssets.map(prefetchHelper)).then(() => {
|
||||
Promise.all(chunkAssetsNeeded.map(prefetchHelper)).then(() => {
|
||||
fetched[routePath] = true;
|
||||
});
|
||||
return true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue