Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

113
Views
WordPress how to enqueue custom script on frontend and avoid enqueueing it on the admin panel

I'm loading a custom script (app-min.js) into a WordPress site. From the site's functions.php:

wp_enqueue_script('app-min', get_template_directory_uri() . '/app/app-min.js', false, 1.0, true);

Works fine on the frontend, but the script is also loaded in the admin panel:

Screenshot, DevTools showing custom script being loaded in WordPress admin panel

Why is this happening and how can I avoid it?

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You could exclude it from the admin panel by using is_admin condition. So your code would be something like this:

if(!is_admin()){
  wp_enqueue_script('app-min', get_template_directory_uri() . '/app/app-min.js', false, 1.0, true);
}

is_adminDocs

Let me know if it works for you!

about 4 years ago · Juan Pablo Isaza Report

0

Please use the hook 'wp_enqueue_scripts' to enqueue css and js meant to be specifically used only on frontend. More details on https://developer.wordpress.org/reference/hooks/wp_enqueue_scripts/

function theme_enqueue_script() {
    wp_enqueue_script('app-min', get_template_directory_uri() . '/app/app-min.js', false, 1.0, true);
}
add_action( 'wp_enqueue_scripts', 'theme_enqueue_script' );
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!