wp_dequeue_script VS Deleting the script from functions.php

firstly please pardon my complete ignorance in regards to WordPress and Web Development in general if in being completely honest.

I have a theme on my website which came with a whole bunch of Javascript addons (like pretty photo) that i dont want. There are literally tons of them. Now, i want to remove the relevant files altogether, but that will result in 404 on those files (which wont help with my load times).

Read More

My question, i have been reading an aweful lot about wp_dequeue_script , and how it removes files.
Why not just delete the actual wp_enqueue_ files from function.php??

Does that cause problems? Any insight into the matter would be much appreciated.

Related posts

Leave a Reply

1 comment

  1. Welcome to the world of WordPress.

    Why not just delete the actual wp_enqueue_ files from function.php??

    The only answer and explanation to this question is, if you are not the author of a plugin or theme, never make any type of modification to that plugin or theme. This also goes for WordPress core files. The simple reason being, if you ever upgrade your theme/plugin/core, all your changes will be lost and cannot be retrieved. This is a very costly mistake

    The proper way

    In your case, you should use functions like wp_deregister_script() and wp_dequeue_script() to remove scripts you don’t need. See this post on how to correctly remove scripts.

    This functions should go in either a custom plugin or a child theme. This should never go into the theme directly as this will be deleted when you update your theme.

    I hope this helps