web: Speed optimization

This commit is contained in:
Hajime Hoshi 2019-09-26 22:11:16 +09:00
parent b4969cccd7
commit 9a42b264fd

View File

@ -25,23 +25,31 @@ func IsBrowser() bool {
return true return true
} }
var userAgent = js.Global().Get("navigator").Get("userAgent").String() var (
userAgent = js.Global().Get("navigator").Get("userAgent").String()
isIOSSafari bool
isAndroidChrome bool
)
func init() {
isIOSSafari = strings.Contains(userAgent, "iPhone")
if !strings.Contains(userAgent, "Android") {
isAndroidChrome = false
}
if !strings.Contains(userAgent, "Chrome") {
isAndroidChrome = false
}
isAndroidChrome = true
}
func IsIOSSafari() bool { func IsIOSSafari() bool {
if !strings.Contains(userAgent, "iPhone") { return isIOSSafari
return false
}
return true
} }
func IsAndroidChrome() bool { func IsAndroidChrome() bool {
if !strings.Contains(userAgent, "Android") { return isAndroidChrome
return false
}
if !strings.Contains(userAgent, "Chrome") {
return false
}
return true
} }
func IsMobileBrowser() bool { func IsMobileBrowser() bool {