Skip to content

Instantly share code, notes, and snippets.

@tzkmx
Created July 21, 2017 16:22
Show Gist options
  • Save tzkmx/06430ab15a7b29782b083653692dd2d3 to your computer and use it in GitHub Desktop.
Save tzkmx/06430ab15a7b29782b083653692dd2d3 to your computer and use it in GitHub Desktop.
Force footer registration of scripts for lazyload when assetsminify plugin present
<?php
/** After registering scripts, A3 Lazy Load plugin fires action
* we use to fix registration, adding data to load it
* in footer, because assetsminify mangles the order of files */
add_action('after_a3_lazy_load_xt_script', function() {
$plugins = get_option('active_plugins');
if( in_array('assetsminify/plugin.php', $plugins) ) {
$scripts = wp_scripts();
foreach($scripts->registered as $handle => $dep) {
if( false !== strpos( $handle, 'lazyloadxt' ) ) {
$scripts->add_data($handle, 'group', 1);
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment