소스 검색

Guard navigator.connection.effectiveType

to avoid JS Errors
`navigator.connection.effectiveType` might not be present in Firefox 68.0 though `navigator.connection` is and `navigator.connection.saveData` might be as well
pieded 5 년 전
부모
커밋
6f3df254eb
1개의 변경된 파일1개의 추가작업 그리고 1개의 파일을 삭제
  1. 1 1
      instantpage.js

+ 1 - 1
instantpage.js

@@ -24,7 +24,7 @@ if ('instantIntensity' in document.body.dataset) {
     }
   }
   else if (intensity.substr(0, 'viewport'.length) == 'viewport') {
-    if (!(navigator.connection && (navigator.connection.saveData || navigator.connection.effectiveType.includes('2g')))) {
+    if (!(navigator.connection && (navigator.connection.saveData || (navigator.connection.effectiveType && navigator.connection.effectiveType.includes('2g'))))) {
       if (intensity == "viewport") {
         /* Biggest iPhone resolution (which we want): 414 × 896 = 370944
          * Small 7" tablet resolution (which we don’t want): 600 × 1024 = 614400