a child theme not de-registering a patent javascript file

We’re currently rolling out a number (>100) of wordpress sites where we’re using a custom child theme and a holding page plugin.

Most of our clients use IE8 as their browser (corporate policy) and unfortunately their appears to be a conflict between the holding page plugin and an external javascript file included by the parent theme, set in it’s functions.php file.

Read More
wp_register_script('iejs', 'http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js');

I’ve tried to prevent the JS file from being called by adding

wp_deregister_script('iejs');
wp_dequeue_script('iejs');

N.B. I guess using but deregister and dequeue is overkill but I want to be sure I’ve de-registered it…

to the child theme functions.php but that didn’t work (prevent the javascript file being called by wp_head), I read somewherre that child themes are called pre the parent theme so I tried

function SAH_dereg() {
    wp_deregister_script('iejs');
    wp_dequeue_script('iejs');
}
add_action( 'after_setup_theme', 'SAH_dereg' );

to force it to de-register the script after the theme loads but before it displays, but that didn’t work either.

We could of course just remove the line from the parent theme and ignore any updates until after we’ve sign off from our clients. But I’d prefer a more elegant solution.

Related posts

1 comment

  1. This is not th right hook, try wp_enqueue_scriptsinstead :

    add_action( 'wp_enqueue_scripts', 'SAH_dereg' );
    

Comments are closed.