Modern-browsers
API for defining the boundary between modern and legacy JavaScript clients.
You can use this package to define the minimum browser versions for which a browser engine will be considered modern. All browsers that do not meet the threshold will receive the legacy bundle. This way you can easily keep on using modern features that you need.
You can read more about this in Meteor 1.7 announcement blog.
ModernBrowsers.isModern server only
server only
Summary:
Given a { name, major, minor, patch } object like the one provided by webapp via request.browser, return true if that browser qualifies as "modern" according to all requested version constraints.
Arguments:
Source codeName | Type | Description | Required |
---|---|---|---|
browser | object | { name: string, major: number, minor?: number, patch?: number } | No |
import { ModernBrowsers } from "meteor/modern-browsers";
/** @returns boolean */
const result = ModernBrowsers.isModern(
browser
);
ModernBrowsers.setMinimumBrowserVersions server only
server only
Summary:
Any package that depends on the modern-browsers package can call this function to communicate its expectations for the minimum browser versions that qualify as "modern." The final decision between web.browser.legacy and web.browser builds will be based on the maximum of all requested minimum versions for each browser.
Arguments:
Source codeName | Type | Description | Required |
---|---|---|---|
versions | object | Name of the browser engine and minimum version for at which it is considered modern. For example: { chrome: 49, edge: 12, ie: 12, firefox: 45, mobileSafari: 10, opera: 38, safari: 10, electron: [1, 6], } | Yes |
source | function | Name of the capability that requires these minimums. | Yes |
import { ModernBrowsers } from "meteor/modern-browsers";
ModernBrowsers.setMinimumBrowserVersions(
versions,
() => {},
);
ModernBrowsers.getMinimumBrowserVersions server only
server only
Summary:
Returns an object that lists supported browser engines and their minimum versions to be considered modern for Meteor.
ModernBrowsers.calculateHashOfMinimumVersions
Summary:
Creates a hash of the object of minimum browser versions.
Configure Unknown Browsers to default to Modern
Browsers not explicitly listed in setMinimumBrowserVersions
are considered "legacy" by default.
To change this and treat unknown browsers as "modern," update the relevant option in your settings file:
Meteor.settings.packages = {
"modern-browsers": {
"unknownBrowsersAssumedModern": true
}
};