0

When I load my website, I see many java scripts and css loading and slowing my website. Many of them I know I'm not using, like fonts, extra theme css from a template that I'm not using, icons and so on.

I've tried to locate them in functions.php but no success. Can I just remove the files from the server, or should I disable it somewhere else?

closed as off-topic by Jacob Peattie, fuxia Sep 27 '18 at 9:21

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

  • If your theme is ready made then you need to check register-scripts file in your theme where all scripts and styles sheet file included and remove it as per your requirement. – Pratik Patel Sep 27 '18 at 7:39
  • @PratikPatel Not every theme is going to have a 'register-scripts' file. Nor will they necessarily register scripts and styles all in one place. Only fool proof way to find this stuff is to look through every file or contact the author. – Jacob Peattie Sep 27 '18 at 7:56
1

You should locate all wp_register_script instances (they can be incuded in core, plugin, theme, anywhere) and in your functions.php you can deregister them

add_action( 'wp_enqueue_scripts', 'my_scripts_method' );
function my_scripts_method() {
    // if you want to exclude built-in jQuery
    wp_deregister_script('jquery');
}

All scripts that can be enqueued by Wordpress are listed (there are handles of each) in codex

  • Make sure, add_action() is called with a high enough priority, that all scripts will be registered by the time the function is called – kero Sep 27 '18 at 8:28

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