File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -42,6 +42,12 @@ function extractInViewportLinks(el) {
4242export default function quicklink ( options ) {
4343 options = options || { } ;
4444 requestIdleCallback ( ( ) => {
45+ if ( 'connection' in navigator ) {
46+ // Don't prefetch if the user is on 2G..
47+ if ( navigator . connection . effectiveType && / \s l o w - 2 g | 2 g / . test ( navigator . connection . effectiveType ) ) {
48+ return ;
49+ }
50+ }
4551 // Prefetch an array of URLs if supplied (as an override)
4652 if ( options . urls !== undefined && options . urls . length > 0 ) {
4753 fetchLinks ( options . urls ) ;
@@ -50,7 +56,9 @@ export default function quicklink(options) {
5056 let el = options . el || document ;
5157 extractInViewportLinks ( el ) . then ( ( urls ) => {
5258 fetchLinks ( urls ) ;
53- } ) ;
54- }
59+ } ) ;
60+ }
5561 } ) ;
5662}
63+
64+ // TODO: add preload / high prio?
You can’t perform that action at this time.
0 commit comments