Skip to content

Commit 526d6a0

Browse files
authored
ENGCOM-7285: [PERF Improvements]Load polyfills for browsers that don't support certain features #27618
2 parents b1b1d99 + 0a39260 commit 526d6a0

File tree

6 files changed

+31
-10
lines changed

6 files changed

+31
-10
lines changed

app/code/Magento/Ui/view/base/requirejs-config.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*/
55

66
var config = {
7+
deps: [],
78
shim: {
89
'chartjs/Chart.min': ['moment'],
910
'tiny_mce_4/tinymce.min': {
@@ -30,3 +31,29 @@ var config = {
3031
}
3132
}
3233
};
34+
35+
/**
36+
* Adds polyfills only for browser contexts which prevents bundlers from including them.
37+
*/
38+
if (typeof window !== 'undefined' && window.document) {
39+
/**
40+
* Polyfill Map and WeakMap for older browsers that do not support them.
41+
*/
42+
if (typeof Map === 'undefined' || typeof WeakMap === 'undefined') {
43+
config.deps.push('es6-collections');
44+
}
45+
46+
/**
47+
* Polyfill MutationObserver only for the browsers that do not support it.
48+
*/
49+
if (typeof MutationObserver === 'undefined') {
50+
config.deps.push('MutationObserver');
51+
}
52+
53+
/**
54+
* Polyfill FormData object for old browsers that don't have full support for it.
55+
*/
56+
if (typeof FormData === 'undefined' || typeof FormData.prototype.get === 'undefined') {
57+
config.deps.push('FormData');
58+
}
59+
}

app/code/Magento/Ui/view/base/web/js/lib/core/events.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
/* global WeakMap, Map*/
77
define([
88
'ko',
9-
'underscore',
10-
'es6-collections'
9+
'underscore'
1110
], function (ko, _) {
1211
'use strict';
1312

app/code/Magento/Ui/view/base/web/js/lib/knockout/extender/bound-nodes.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ define([
88
'ko',
99
'underscore',
1010
'mage/utils/wrapper',
11-
'uiEvents',
12-
'es6-collections'
11+
'uiEvents'
1312
], function (ko, _, wrapper, Events) {
1413
'use strict';
1514

app/code/Magento/Ui/view/base/web/js/lib/registry/registry.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
/* global WeakMap */
1010
define([
1111
'jquery',
12-
'underscore',
13-
'es6-collections'
12+
'underscore'
1413
], function ($, _) {
1514
'use strict';
1615

app/code/Magento/Ui/view/base/web/js/lib/view/utils/dom-observer.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
define([
66
'jquery',
77
'underscore',
8-
'MutationObserver',
98
'domReady!'
109
], function ($, _) {
1110
'use strict';

app/code/Magento/Ui/view/base/web/js/lib/view/utils/raf.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44
*/
55

66
/* global WeakMap */
7-
define([
8-
'es6-collections'
9-
], function () {
7+
define([], function () {
108
'use strict';
119

1210
var processMap = new WeakMap(),

0 commit comments

Comments
 (0)