perf(v2): reduce main bundle size by using es5 if possible (#1979)

This commit is contained in:
Endi 2019-11-13 15:01:04 +07:00 committed by Yangshun Tay
parent 245b50f6e0
commit 8242c0eb00
2 changed files with 3 additions and 4 deletions

View file

@ -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();
}

View file

@ -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;