diff --git a/system/image/image.go b/system/image/image.go index 3cd1022..aebd112 100644 --- a/system/image/image.go +++ b/system/image/image.go @@ -87,6 +87,12 @@ func Fetch(name string, options ...Option) (string, error) { return "", err } + // If we are running in the browser, we reduce the color pair count to 2 + // as the algorithm is very slow running in WASM. + if runtime.GOOS == "js" { + imejiOptions = append(imejiOptions, imeji.WithColorPairMax(2)) + } + if res, err := getCache(hash); err == nil { return string(res.([]byte)), nil } @@ -127,6 +133,12 @@ func FetchAnimation(name string, options ...Option) ([]string, error) { return nil, err } + // If we are running in the browser, we reduce the color pair count to 2 + // as the algorithm is very slow running in WASM. + if runtime.GOOS == "js" { + imejiOptions = append(imejiOptions, imeji.WithColorPairMax(2)) + } + if res, err := getCache(hash); err == nil { return res.([]string), nil }