File tree 2 files changed +12
-4
lines changed 2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -22,16 +22,23 @@ define([
22
22
*/
23
23
function init ( el , config , component ) {
24
24
require ( [ component ] , function ( fn ) {
25
+ var $el ;
25
26
26
27
if ( typeof fn === 'object' ) {
27
28
fn = fn [ component ] . bind ( fn ) ;
28
29
}
29
30
30
31
if ( _ . isFunction ( fn ) ) {
31
- fn ( config , el ) ;
32
- } else if ( $ ( el ) [ component ] ) {
33
- $ ( el ) [ component ] ( config ) ;
32
+ fn = fn . bind ( null , config , el ) ;
33
+ } else {
34
+ $el = $ ( el ) ;
35
+
36
+ if ( $el [ component ] ) {
37
+ fn = $el [ component ] . bind ( $el , config ) ;
38
+ }
34
39
}
40
+ // Init module in separate task to prevent blocking main thread.
41
+ setTimeout ( fn ) ;
35
42
} , function ( error ) {
36
43
if ( 'console' in window && typeof window . console . error === 'function' ) {
37
44
console . error ( error ) ;
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ define([
16
16
17
17
/**
18
18
* Init all components defined via data-mage-init attribute.
19
+ * Execute in a separate task to prevent main thread blocking.
19
20
*/
20
- $ ( mage . apply ) ;
21
+ setTimeout ( mage . apply ) ;
21
22
} ) ;
You can’t perform that action at this time.
0 commit comments