Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent style assets being enqueued at head with 'wp_footer' load hook set #20

Open
wants to merge 1 commit into
base: production
Choose a base branch
from

Conversation

amorphine
Copy link

Thank you for the plugin, it makes life much easer)

There's an issue I have a proposal pull request for.

sync or preload style assets are printed at header even with wp_footerload hook. That happens if we call am_enqueue_script on wp_enqueue_scripts Wordpress cycle. Example at functions.php:

add_action( 'wp_enqueue_scripts',function() {
    am_enqueue_style([
        'handle'      => 'home-styles',
        'src'         => get_stylesheet_directory_uri().'/assets/dist/home.css',
        'deps'        => [],
        'condition'   => 'home',
        'load_method' => 'preload', // sync won't work too
        'version'     => $buildVersion,
        'load_hook'   => 'wp_footer',
        'media'       => 'all',
    ]);
}, 10 );

With preload or sync load method the tag with an asset will be enqueued at the head even if load_hook is wp_footer.

…queued at header

* generate_asset_error doc fix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant