33/* global jQuery */
44var vizClipboard1 = null ;
55( function ( $ , visualizer ) {
6-
6+
77 function initActionsButtons ( v ) {
88 if ( $ ( 'a.visualizer-chart-shortcode' ) . length > 0 && vizClipboard1 === null ) {
99 vizClipboard1 = new ClipboardJS ( 'a.visualizer-chart-shortcode' ) ; // jshint ignore:line
@@ -107,20 +107,10 @@ var vizClipboard1=null;
107107 registerDefaultActions ( ) ;
108108 } ) ;
109109
110- // Refresh charts if chart not generated.
111- function refreshEachCharts ( ) {
112- if ( 'object' === typeof window . fusionAnimationsVars ) {
113- return ;
114- }
115- setTimeout ( function ( ) {
116- displayChartsOnFrontEnd ( ) ;
117- } , 100 ) ;
118- }
119-
120110 function initChartDisplay ( ) {
121111 if ( visualizer . is_front == true ) { // jshint ignore:line
122112 displayChartsOnFrontEnd ( ) ;
123- } else {
113+ } else {
124114 showChart ( ) ;
125115 }
126116 }
@@ -138,14 +128,15 @@ var vizClipboard1=null;
138128 }
139129
140130 function displayChartsOnFrontEnd ( ) {
141- // display all charts that are NOT to be lazy-loaded.
142- $ ( 'div.viz-facade-loaded:not(.visualizer-lazy):not(.visualizer-cw-error):empty' ) . removeClass ( 'viz-facade-loaded' ) ;
143- $ ( 'div.visualizer-front:not(.visualizer-lazy):not(.viz-facade-loaded)' ) . each ( function ( index , element ) {
131+
132+ $ ( 'div.visualizer-front:not(.viz-facade-loaded):not(.visualizer-lazy):not(.visualizer-cw-error):empty' ) . each ( function ( index , element ) {
144133 if ( $ ( element ) . is ( ':visible' ) ) {
145134 var id = $ ( element ) . addClass ( 'viz-facade-loaded' ) . attr ( 'id' ) ;
146- showChart ( id ) ;
135+ setTimeout ( function ( ) {
136+ // Add a short delay between each chart to avoid overloading the browser event loop.
137+ showChart ( id ) ;
138+ } , ( index + 1 ) * 100 ) ;
147139 }
148- refreshEachCharts ( ) ;
149140 } ) ;
150141
151142 // interate through all charts that are to be lazy-loaded and observe each one.
0 commit comments