2

i have a site:, http://liebeundsprueche.com/ I see some js files in source: view-source:http://liebeundsprueche.com/ I have no idea from where these files come:

<link rel='stylesheet' id='dashicons-css'  <href='http://liebeundsprueche.com/wp-includes/css/dashicons.min.css?ver=4.9.1' type='text/css' media='all' />
<link rel='stylesheet' id='admin-bar-css'  href='http://liebeundsprueche.com/wp-includes/css/admin-bar.min.css?ver=4.9.1' type='text/css' media='all' />
<link rel='stylesheet' id='yoast-seo-adminbar-css'  href='http://liebeundsprueche.com/wp-content/plugins/wordpress-seo/css/dist/adminbar-591.min.css?ver=5.9.1' type='text/css' media='all' />
<link rel='stylesheet' id='style-css'  href='http://liebeundsprueche.com/wp-content/themes/tema/style.css?ver=20130606' type='text/css' media='all' />
<script type='text/javascript' src='http://liebeundsprueche.com/wp-includes/js/jquery/jquery.js?ver=1.12.4'></script>
<script type='text/javascript' src='http://liebeundsprueche.com/wp-includes/js/jquery/jquery-migrate.min.js?ver=1.4.1'></script>
<script type='text/javascript' src='http://liebeundsprueche.com/wp-content/themes/tema/js/small-menu.js?ver=4.9.1'></script>
<link rel='https://api.w.org/' href='http://liebeundsprueche.com/wp-json/' />

I want to collect al js files and compress in one js files, what can be easy for browser and search engines to read them. It would bbe best practise but have no idea where can i find them.. I checked and wp theme doesn't do this. It is from Wordpress itself, maybe from wp-include but don't know exactly

  • 1
    Yes, they are from WordPress directly. They are probably correctly added via wp_enqueue_script. Plugins like Autoptimize already do this job for you, why not use them/check their code, how they do it? – kero Dec 11 '17 at 8:59
  • How can i do it? – vangogh94 Dec 11 '17 at 9:22
  • To do it manually you would deregister and dequeue every script, then paste them yourself into a new minified file. But keep in mind every time any of your themes or plugins has an update, you'll have to make sure to manually go back and paste the new code again. It would be a lot more maintainable to just use a plugin like Autoptimize that's already been suggested. Details on dequeue and deregister: wordpress.stackexchange.com/questions/189985/… – WebElaine Dec 11 '17 at 16:43
2

Quick but not recommended solution - remove wp_head() function from your header.php file. NOT RECOMMENDED, because new plugins may not work once you did this.

The best way is to find that files in you theme code, just perform a search within your theme files for wp_enqueue_script - you have to find the hook where this files are connected and you can remove this files just by removing/commenting the appropriate line of code. This method is better but it is still not a perfect way in case it is not your custom theme.

The best way if you are using not your own custom theme is to disconnect those files with wp_dequeue_script() and wp_deregister_script() function. But you have to read these function docs to learn how to do it.

https://codex.wordpress.org/Function_Reference/wp_dequeue_script https://codex.wordpress.org/Function_Reference/wp_deregister_script

  • You can use the plugin Debug Objects to get all loaded scripts and styles to find his source and dependencies. Maybe this helps you also to understand it. – bueltge Dec 12 '17 at 6:02

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.