Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

My parent theme (Starkers) adds a CSS file that I'm trying to remove (I want to use @import instead so I can override styles more easily). Starkers has the following in its functions.php:

add_action( 'wp_enqueue_scripts', 'script_enqueuer' );

function script_enqueuer() {
    wp_register_script( 'site', get_template_directory_uri().'/js/site.js', array( 'jquery' ) );
    wp_enqueue_script( 'site' );

    wp_register_style( 'screen', get_template_directory_uri().'/style.css', '', '', 'screen' );
    wp_enqueue_style( 'screen' );

I've tried the following in the child functions.php, but the link and script tags still show up in the head section.

add_action('init', 'removeScripts');
function removeScripts() {

I've double checked to see if they are hard coded in the parent header and they are not.

Thanks for the help!

share|improve this question

1 Answer 1

up vote 11 down vote accepted

I want to use @import instead so I can override styles more easily

Simply. Don't. Do. That.

You simply jump into the same hook and then deregister/dequeue the styles/scripts and throw in your custom ones.

function PREFIX_remove_scripts() {
    wp_dequeue_style( 'screen' );
    wp_deregister_style( 'screen' );

    wp_dequeue_script( 'site' );
    wp_deregister_script( 'site' );

    // Now register your styles and scripts here
add_action( 'wp_enqueue_scripts', 'PREFIX_remove_scripts', 20 );
share|improve this answer
I want the base styles from Starkers but want to be able to override them, which is why I want to use @import in style.css (currently the base theme styles are loaded after the child theme, which makes it impossible to override the styles without making the css selectors more specific). –  jmotes Sep 18 '12 at 17:04
You're absolutely right though with your code. I was able to get the script to dequeue after adding the priority so that the child dequeue code runs last. Thank you! –  jmotes Sep 18 '12 at 17:05
Note that if you'd like to be able to use either of those handles ('screen' or 'site') after dequeuing them, you'll need to deregister them too. For instance: wp_deregister_style( 'screen' ); and wp_deregister_script( 'site' ); –  peterjmag Oct 18 '12 at 18:29
@peterjmag You're absolutely right on this topic. Please do an edit (afaik, gives you 2 rep points per upvote on this answer). Thanks. –  kaiser Oct 18 '12 at 19:02

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.