0

I am currently developing a child theme that builds on twentyfifteen as a parent theme. However a potential issue has cropped up that is causing a problem.

I want to strip the CSS and JS assets from the parent theme twentyfifteen, but these are loaded from the theme's functions.php file with wp_enqueue_style and wp_enqueue_script, I have commented out these lines in the functions.php file so that now these CSS and JS assets are not longer loaded - but isn't it he case that if an update is released for the twentyfifteen parent theme, that when it is updated - the functions.php file will be overwritten along with any commenting out I have done. So in other words when it is updated the unwanted CSS and JS assets will be reloaded.

What is the best solution here? Can I prevent twentyfifteen loading it's stylesheet and JS without editing it's functions.php file (as this file will only be updated and changes overwritten?) Surely there is a better way of doing this.

I'm currently developing a child theme for with a base of twentyfifteen and have been left wondering if it would just be best to create an independent theme rather than a child theme as a workaround to this issue.

1

You have two options here

  • In a child theme, dequeue and deregister the scripts and style you are not going to need. Just remember to hook your function to wp_enqueue_scripts with a lower priority (higher number)

  • Use the twentyfifteen as a base to a new theme. I have successfully used bundled themes in the past to create new, selfstanding themes. That is one of the reasons the bundled themes are there for. The only thing you really need to change is the stylesheet header to something unique to avoid updates, and then make and break as you like.

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.