diff --git a/src/AssetsMinify/Init.php b/src/AssetsMinify/Init.php index 9a5c7c2..dbc37bb 100644 --- a/src/AssetsMinify/Init.php +++ b/src/AssetsMinify/Init.php @@ -39,12 +39,14 @@ public function __construct() { //Detects all js and css added to WordPress and removes their inclusion if( get_option('am_compress_styles', 1) ) add_action( 'wp_print_styles', array( $this->css, 'extract' ) ); - if( get_option('am_compress_scripts', 1) ) + if( get_option('am_compress_scripts', 1) ) { add_action( 'wp_print_scripts', array( $this->js, 'extract' ) ); + add_action( 'wp_print_footer_scripts', array( $this->js, 'extract' ), 5 ); + } //Inclusion of scripts in and before add_action( 'wp_head', array( $this, 'header' ) ); - add_action( 'wp_footer', array( $this, 'footer' ) ); + add_action( 'wp_print_footer_scripts', array( $this, 'footer' ), 6 ); } /** @@ -77,4 +79,4 @@ public function footer() { if ( $this->cache->isUpdated() ) Log::getInstance()->dumpStorage(); } -} \ No newline at end of file +}