File tree Expand file tree Collapse file tree 2 files changed +12
-4
lines changed
Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -22,16 +22,23 @@ define([
2222 */
2323 function init ( el , config , component ) {
2424 require ( [ component ] , function ( fn ) {
25+ var $el ;
2526
2627 if ( typeof fn === 'object' ) {
2728 fn = fn [ component ] . bind ( fn ) ;
2829 }
2930
3031 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+ }
3439 }
40+ // Init module in separate task to prevent blocking main thread.
41+ setTimeout ( fn ) ;
3542 } , function ( error ) {
3643 if ( 'console' in window && typeof window . console . error === 'function' ) {
3744 console . error ( error ) ;
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ define([
1616
1717 /**
1818 * Init all components defined via data-mage-init attribute.
19+ * Execute in a separate task to prevent main thread blocking.
1920 */
20- $ ( mage . apply ) ;
21+ setTimeout ( mage . apply ) ;
2122} ) ;
You can’t perform that action at this time.
0 commit comments