iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more
Choose a WordPress enqueue hook by where the asset should appear: use wp_enqueue_scripts for the public site, admin_enqueue_scripts for dashboard screens, login_enqueue_scripts for login and registration, and enqueue_block_assets for block assets shared between the editor and front end. The easily confused enqueue_block_editor_assets is for the block editing interface itself.
Which WordPress enqueue hook should you use?
| Hook | Destination | Typical audience | Use it for |
|---|---|---|---|
wp_enqueue_scripts |
Public front end | Site visitors | Scripts and styles for public pages. WordPress Developer Resources |
admin_enqueue_scripts |
Administration screens | Site administrators and other dashboard users | Scripts and styles for admin pages; use its page-hook suffix to target a particular screen. WordPress Developer Resources |
login_enqueue_scripts |
Login and registration screens | People authenticating or registering | Scripts and styles for the login experience. WordPress Developer Resources |
enqueue_block_assets |
Block content on the front end and in the editor | Visitors and content editors | Assets intended to accompany blocks in both contexts. Since WordPress 6.3, assets added through this hook are also enqueued in the editor iframe. WordPress Developer Resources |
enqueue_block_editor_assets |
Block editing interface | Content editors | Assets that belong to the editor interface rather than shared block content. WordPress Developer Resources |
Despite their names, both wp_enqueue_scripts and admin_enqueue_scripts are used to enqueue styles as well as scripts. WordPress describes the front-end action as the proper hook for scripts and styles meant to appear on the front end, and the admin action as the proper hook for assets meant for the administration panel.
How to enqueue front-end assets
Attach your callback to wp_enqueue_scripts when an asset belongs on public-facing pages. The wp_enqueue_scripts() function is a wrapper for that action; it runs first in wp_head(), where conditional functions such as is_home() and is_page() are available. WordPress Developer Resources
add_action( 'wp_enqueue_scripts', 'mytheme_enqueue_frontend_assets' );
function mytheme_enqueue_frontend_assets() {
if ( is_page() ) {
wp_enqueue_style(
'mytheme-page-style',
get_stylesheet_directory_uri() . '/page.css'
);
}
}
The conditional keeps this example’s stylesheet on pages rather than every front-end request. Change or remove the condition to match the pages your asset actually supports.
#1 Best Overall
How to limit assets to an administration screen
Use admin_enqueue_scripts for dashboard assets. Its callback receives the current screen’s hook suffix, which lets you avoid loading CSS or JavaScript on unrelated admin pages. WordPress warns that enqueueing assets across all admin screens can cause conflicts or degrade the admin experience. Hook reference · Script function reference
add_action( 'admin_enqueue_scripts', 'myplugin_enqueue_admin_assets' );
function myplugin_enqueue_admin_assets( $hook_suffix ) {
if ( 'tools_page_my-plugin' !== $hook_suffix ) {
return;
}
wp_enqueue_style(
'myplugin-admin-style',
plugin_dir_url( __FILE__ ) . 'admin.css'
);
}
Replace tools_page_my-plugin with the suffix for the screen you intend to target. The important pattern is to inspect the passed suffix and return early on screens that do not need the asset.
How to enqueue login or registration assets
Use login_enqueue_scripts when CSS or JavaScript is meant for the WordPress login experience, including registration screens handled there. The name can sound script-only, but the hook is also suitable for styles. WordPress Developer Resources
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
add_action( 'login_enqueue_scripts', 'mytheme_enqueue_login_style' );
function mytheme_enqueue_login_style() {
wp_enqueue_style(
'mytheme-login-style',
get_stylesheet_directory_uri() . '/login.css'
);
}
Block assets: shared content or editor interface?
Use enqueue_block_assets for assets shared by blocks
This action runs after block assets are enqueued and covers both the front end and editor. Since WordPress 6.3, assets added through it are also enqueued for the editor iframe. It is the right fit when block content needs the asset in both places, rather than only when an editor is open. WordPress Developer Resources
Rank #3
If the asset should be limited to the editor after WordPress 6.3, the hook reference shows an is_admin() check as a way to restrict it. Choose the condition based on the destination you intend, since the shared hook otherwise serves front-end and editor contexts.
Use enqueue_block_editor_assets for the editing interface
This hook targets the block editor interface. Use it for editor-specific functionality or presentation that should not be enqueued on the public front end; do not substitute it for shared block content assets. WordPress Developer Resources
Rank #4
- Keep track of everything from attendance to test scores
- Spiral bound
- Measures 8-1/2" x 11"
A quick way to avoid mixing the hooks up
- Identify the destination. Public page:
wp_enqueue_scripts. Dashboard page:admin_enqueue_scripts. Login or registration:login_enqueue_scripts. - For block-related assets, decide whether the asset belongs to content or the editing interface. Shared block content:
enqueue_block_assets. Editor UI only:enqueue_block_editor_assets. - Narrow the scope when needed. Use the admin hook suffix to target one dashboard screen, and use appropriate front-end conditions when only certain public pages need an asset.
The reliable rule is to match the hook to the asset’s destination and audience, not to choose one familiar enqueue action for every request.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Fix the driver behind crashes, sound loss and screen glitches3Repair Windows errors before they cause bigger problemsQuick Recap
Best Value
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

