0

New to WordPress. I have been working on my own child theme. Everything is working so far but I have a question on dequeuing a parent theme's CSS.

Right now, the parent theme enqueues a AOS.css file which adds "action of scroll". I am not a big fan of this effect and want to dequeue this style entirely in my child theme. My question is if I dequeue but the parent theme still includes AOS related stuff would that crash the site or I can safely remove AOS.css?

1
  • 1
    You should be good to dequeue it, but you may then need to address certain styling deficiencies by writing them into your child style.css. May 3 '20 at 22:21
0

Tony has it right, you can dequeue the style without the site having an error. That is because of the way CSS works. If the DOM can't find a specific CSS class/ID that is in the HTML it is simply ignored. Tony is also right, that you may need to add some styles back in if they were included in the, now removed, CSS file.

If you were removing a JavaScript file on the other hand you would need to be more careful to make sure that one of the removed functions wasn't going to cause a conflict elsewhere. A quality theme developer will take that into consideration and often wrap functions to make sure all functions are there, but that's not always the case.

0

Try this code in the currently existing theme for the dequeue style.

add_action( 'wp_enqueue_scripts', 'mywptheme_child_deregister_styles', 11 );
function mywptheme_child_deregister_styles() {
    wp_dequeue_style( 'mywptheme' );
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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