Enqueue a dependency for non admin users

Hello,

Whats the best way to load a dependency for a specific page, or in my case “not for the admin”

I’ve tried the below within the function assets() but it doesn’t seem to make any difference.

if( !is_admin()){
wp_enqueue_script(‘dependencies’, Assets\asset_path(‘scripts/dependencies.js’), [], null, true);
}

Thanks, Stephen

WordPress conditionals like the one you’re using work as expected in the same place you’re using it.

Impossible :slight_smile: But seriously… if you’re not an admin then it will load that script. If you’re seeing otherwise then make sure you’re looking at the same install that you’re actually making changes to.

1 Like