Created
December 21, 2020 11:26
-
-
Save jakub-g/b55cb5a30d1dea24b5ff1226a23c2a29 to your computer and use it in GitHub Desktop.
legacy-browser-detection-ua-sniffing.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
var isIE = typeof document.documentMode !== 'undefined' | |
var chromeVersion = navigator.userAgent.match(/Chrome\/(\d+)/) || undefined | |
chromeVersion = chromeVersion && parseInt(chromeVersion[1]) | |
var firefoxVersion = navigator.userAgent.match(/Firefox\/(\d+)/) || undefined | |
firefoxVersion = firefoxVersion && parseInt(firefoxVersion[1]) | |
var edgeVersion = navigator.userAgent.match(/Edge\/(\d+)/) || undefined | |
edgeVersion = edgeVersion && parseInt(edgeVersion[1]) | |
var safariVersion = (!chromeVersion && !navigator.userAgent.match(/Tizen/) | |
&& navigator.userAgent.match(/Version\/(\d+).*Safari\//)) | |
|| undefined | |
safariVersion = safariVersion && parseInt(safariVersion[1]) | |
// Checking precisely for Safari version = 9 because there are too many false positives | |
// from niche browsers having Version/4 or Version/5 in URL (old Androids, Samsung TV WebViews...) | |
var isLegacy = isIE || chromeVersion < 47 || firefoxVersion < 48 || edgeVersion < 17 || safariVersion === 9 | |
if (isLegacy) { | |
// ... | |
} | |
})(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment