diff --git a/assets/js/customizer-liveview.js b/assets/js/customizer-liveview.js index d316eed7..88769ca9 100644 --- a/assets/js/customizer-liveview.js +++ b/assets/js/customizer-liveview.js @@ -77,17 +77,21 @@ } ); } ); - $( window ).resize( function(){ + function update_css( ){ var css_code = $( '#onepress-style-inline-css' ).html(); // Fix Chrome Lost CSS When resize ?? - $( '#onepress-style-inline-css' ).html( css_code ); + $( '#onepress-style-inline-css' ).replaceWith( '' ); + + } + + // When preview ready + wp.customize.bind( 'preview-ready', function() { + update_css(); }); - setTimeout( function(){ - var css_code = $( '#onepress-style-inline-css' ).html(); - // Fix Chrome Lost CSS When resize ?? - $( '#onepress-style-inline-css' ).html( css_code ); - }, 200 ); + $( window ).resize( function(){ + update_css(); + }); wp.customize.selectiveRefresh.bind( 'partial-content-rendered', function( settings ) {