MultiformeIngegno
Member
Posted 1 year ago #
Hi! :)
I created a theme for WP 3.3.1. Everything works properly, except that I'd like to load jQuery on admin panel only (not "outside").
This is because my websites doesn't need it, I just need it to run the admin pages (media functions to edit the images, the admin menu to work, the wp_nav_menu organization in admin, etc...).
I'd avoid to deregister the built-in script and register another one.. I'd just specify that it should run on admin panel only...
How can I obtain that?
Thanks in advance! :)
What hook are you using to enqueue your script?
MultiformeIngegno
Member
Posted 1 year ago #
Ahem.. actually I don't know.. I presume it's included in <?php wp_head ?> because I don't call it. It's the already built-in jQuery..
jQuery is built into WordPress but what are you using to enqueue your script? I'm assuming you are trying to load a script on the admin side only, yes?
MultiformeIngegno
Member
Posted 1 year ago #
Yes! I created a child theme starting from the TwentyTen theme.. Unfortunately I don't know where jQuery is called in the theme! I just know that it's present in the HTML of my website, so it's somewhere in wp_head. I looked in functions.php, header.php, index.php, footer.php but there's no call to jQuery... can't find it but it's in my website html.. and I want it only loaded in admin panel. :)
I presume it's called with <?php wp_enqueue_script('jquery'); ?>, but can't find it..
OK - let's got back a few steps... what are you trying to do?
MultiformeIngegno
Member
Posted 1 year ago #
:P
Have jQuery only loaded in admin panel. NOT in posts/pages. :)
MultiformeIngegno
Member
Posted 1 year ago #
Because I don't want to load more than 50Kb of stuff without need. :)
Then you need to de-register jQuery based on the is_admin() conditional but, be warned, many themes and/or plugins may not work correctly if you disable jQuery on the front end of your site.
MultiformeIngegno
Member
Posted 1 year ago #
No problem, I don't use plugins. :)
is_admin works for admin only or for editors/authors too..?
`is_admin() = is this the WP admin area (ie the back end of a site).
MultiformeIngegno
Member
Posted 1 year ago #
So this would work..?
<?php
if ( ! is_admin() ) {
wp_enqueue_script('jquery');
} else { }
?>