最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

actions - How do I dequeue jscss at the last possible moment?

programmeradmin3浏览0评论

I'm trying to dequeue the font-awesome stylesheet included with the ninja forms plugin (because I manually include the latest FA via a CDN).

I did this:

add_action('wp_enqueue_scripts', function () {
  wp_dequeue_style('nf-font-awesome');
}, 100);

However the version included in the plugin still loads.

So, how do I dequeue a script or stylesheet at the very last moment? I'm obviously not dequeing "late enough", and that's why the above isn't working.

What is "later" than wp_enqueue_scripts?

I'm trying to dequeue the font-awesome stylesheet included with the ninja forms plugin (because I manually include the latest FA via a CDN).

I did this:

add_action('wp_enqueue_scripts', function () {
  wp_dequeue_style('nf-font-awesome');
}, 100);

However the version included in the plugin still loads.

So, how do I dequeue a script or stylesheet at the very last moment? I'm obviously not dequeing "late enough", and that's why the above isn't working.

What is "later" than wp_enqueue_scripts?

Share Improve this question asked Jan 15, 2020 at 10:29 lonixlonix 3011 silver badge10 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

I used this to determine which actions were firing, and their order:

add_action( 'shutdown', function(){
    foreach( $GLOBALS['wp_actions'] as $action => $count )
        printf( '%s (%d) <br/>' . PHP_EOL, $action, $count );

});

And that showed me that the ninja forms plugin uses a custom action nf_display_enqueue_scripts, which is what I used.

发布评论

评论列表(0)

  1. 暂无评论