ua_parser_js 1.0.1 icon indicating copy to clipboard operation
ua_parser_js: ^1.0.1 copied to clipboard

Platformweb

UAParser from JavaScript library to detect Browser, Engine, OS, CPU, and Device type/model from User-Agent data with relatively small footprint (~17KB minified, ~6KB gzipped) that can be used either i [...]

ua_parser_js #

UAParser from JavaScript

Getting Started #

Include ua-parser-js at /web/index.html

<!doctype html>
<html>
<head>
    <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ua-parser-js@1.0.2/dist/ua-parser.min.js"></script>
</head>
<body>
</body>
</html>

Using HTML #

<!doctype html>
<html>
<head>
    <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ua-parser-js@1.0.2/dist/ua-parser.min.js"></script>
    <script type="text/javascript">
    let parser = new UAParser();
    let result = parser.getResult();
    var useCanvaskit = false;
    if(result.os.name == "Android" && result.browser.major >= 57) {
      useCanvaskit = true
    } else if(result.os.name == "iOS" && result.browser.major >= 11) {
      useCanvaskit = true
    }

    if(useCanvaskit) {
      window.flutterWebRenderer = "canvaskit";
    }

    console.log("canvaskit: " + useCanvaskit);
    console.log(result);
  </script>
</head>
<body>
</body>
</html>

Using Dart #

import 'package:ua_parser_js/ua_parser_js.dart';

String? defaultFontFamily() {
  String? fontFamily;

  var uaParser = UAParser();
  final result = uaParser.getResult();
  print("UAParser: ${result.jsObject()}");
  switch (uaParser.getOS().name) {
    case "iOS":
      fontFamily = "PingFang";
      break;
  }

  print("fontFamily: $fontFamily");
  return fontFamily;
}
1
likes
110
pub points
29%
popularity

Publisher

unverified uploader

UAParser from JavaScript library to detect Browser, Engine, OS, CPU, and Device type/model from User-Agent data with relatively small footprint (~17KB minified, ~6KB gzipped) that can be used either in browser (client-side) or node.js (server-side).

Repository (GitHub)
View/report issues

Documentation

API reference

License

Icon for licenses.MIT (LICENSE)

Dependencies

js

More

Packages that depend on ua_parser_js