User Agent

By supplying a glob that matches browsers' user agent strings , the optimizer can take into account browser specific information. E.g.

if (typeof addEventListener !== 'undefined') {
  myNode.addEventListener(…);
} else if (typeof attachEvent !== 'undefined') {
  myNode.attachEvent(…);
}
could be optimized by taking into account knowledge about the browser to produce
    myNode.addEventListener(…);
on all non-IE browsers, and
    myNode.attachEvent(…);
on IE.

To get best results, use code similar to the tests in ecmascript_snippets.py and if you want to avoid rechecking, store the checks in vars declared at the top of a function body or program:

    var useGetComputedStyle = typeof addEventListener === 'undefined';
    ...

This feature is experimental and should be used with care. The database of user agent info is not complete, so the merge procedure described above may have holes. And some small percentage of browsers spoof the user agent. Optimizations that assume things about the browser based on the user agent will not work.

See the BrowserScope help for more details.