1

I need to remove some external .js files from source here is source: view-source:buhehe.de/ausmalbilder/ There is 3 jquery library and I don't know what is difference, why is it not one enough?

<script type='text/javascript' src='http://buhehe.de/wp-includes/js/jquery/jquery.js?ver=1.12.4'></script>
<script type='text/javascript' src='http://buhehe.de/wp-includes/js/jquery/jquery-migrate.min.js?ver=1.4.1'></script>
<script type="text/javascript" src="http://buhehe.de/wp-content/themes/tema/js/jquery-3.2.1.min.js"></script>

Can I leave only one?

And how can I remove following:

<script type='text/javascript' src='http://buhehe.de/wp-content/themes/heatt/js/small-menu.js?ver=4.9.1'></script>
<script type='text/javascript' src='http://buhehe.de/wp-includes/js/wp-embed.min.js?ver=4.9.1'></script>

2 Answers 2

3

You can use wp_dequeue_script to achieve this assuming they are using wp_enqueue_script to add the scripts in the first place.

Learn more about enquene and dequeue: https://developer.wordpress.org/reference/functions/wp_enqueue_script/ https://codex.wordpress.org/Function_Reference/wp_dequeue_script

function dequeue_script() {
   wp_dequeue_script( 'http://buhehe.de/wp-content/themes/heatt/js/small-menu.js?ver=4.9.1' );
   wp_dequeue_script( 'http://buhehe.de/wp-includes/js/wp-embed.min.js?ver=4.9.1' );
}
add_action( 'wp_print_scripts', 'dequeue_script', 100 );
2
  • 2
    this is not the good use of the functions wp_dequeue_... it's not the URL on the 1st argument but the handle identifier used to enqueue the file.
    – mmm
    Commented Jan 1, 2018 at 19:24
  • @mmm This was just an example of the structure. Commented Jan 2, 2018 at 18:30
2

Firstly: Are you absolutely sure that you don't need them?

Secondly: I'm assuming small-menu.js is for the mobile menu and wp-embed.min.js you want in case you use embeds.
If I'm right, then you might want to keep the former. Aside from that you likely will find a wp_enqueue_script line for the former in your theme's functions.php. For the latter take a look at »What does wp-embed.min.js do in WordPress 4.4?«.
To keep it short and simple about the jQuery lines, WordPress loads jquery.js and jquery-migrate.min.js for compatibility reasons. I would suggest you keep it that way, unless you are really sure what you're doing.
Additionally your theme loads another jQuery source, which generally isn't recommended. But there might be a reason to do so, so it can't be easily answered, if you simply can remove it. You'll likely find this one it the functions.php as a wp_enqueue_script line too.

3
  • I want to combine that small-menu.js, wp-embed.min.js in another html5.js. is it possible? Also better would be one main .js joined, combined and not 3 different .js . is it possible in my case? Commented Dec 27, 2017 at 21:21
  • and about jqueyr,also would it be good if i remove all that .js s and load only one recent jquery library? for what does wordpress loads automatically migrate.min.js and jquery.js? Can it not be loaded only one jquery? main, recent, updated version? Commented Dec 27, 2017 at 21:22
  • @ნიკახაჩიძე Sure, it is possible. It is advised to use the JQuery version bundled with WP. All the information you're asking for is out there and has been answered, perform a research on here and on the net. This thread might interest you. Commented Dec 27, 2017 at 21:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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