How do I detect the browser engine?

How do I detect the browser engine? It is advisable to determine not by the table in the wiki, but programmatically or somewhere in the browser itself.

Author: VenZell, 2016-02-07

1 answers

If you need to define on the client:

There is a javascript library. It is called Layout Engine.

  • Recognizes the following engines: edge, ie, khtml, mozilla, opera and webkit
  • Determines browser versions: ie- 11, 10, 9, 8, 7 and opera- mini
  • Distinguishes the following WebKit browsers: android, chrome (including Opera Blink and Android 5+ WebView), safari, safari-ios, and wiiu.

Here is a demo with this library and its sources.

Example of use in CSS:

.vendor-ie-10 {
    line-height: 20px;
}

.browser-safari-ios .text-input {
    font-size: 16px;
}

If necessary, the browser version, and the browser itself, can be determined inside your JavaScript script using the following methods: layoutEngine.vendor, layoutEngine.version and layoutEngine.browser.

Usage example in JavaScript:

if (layoutEngine.vendor === 'ie' && layoutEngine.version === 10) {
    // Некие действия
}

If you need to define it on the server (for example, in PHP):

There is a package WhichBrowser/Parser for Composer. From the developer html5test.com.

Usage example:

$result = new WhichBrowser\Parser($_SERVER['HTTP_USER_AGENT']);

$result->browser->name;
// Chrome

$result->browser->name . ' ' . $result->browser->version.toString();
// Chrome 27

$result->browser->version->value;
// 27.0.1453.110

$result->engine->name;
// Blink
 3
Author: VenZell, 2016-02-07 21:04:12