I want to optimize the code. When you open my site in the browser's view-source , many unnecessary links are displayed, for example, PageSpeed ​​Insights swears:

 <link rel='stylesheet' id='shortcodes-css' href='http://mysite.net/wp-content/themes/deals/functions/shortcodes/shortcodes.css?ver=4.4.6' type='text/css' media='all' /> <link rel='stylesheet' id='fancybox-css' href='http://mysite.net/wp-content/themes/deals/includes/css/fancybox.css?ver=4.4.6' type='text/css' media='all' /> <link rel='stylesheet' id='jq-ui-css' href='http://mysite.net/wp-content/themes/deals/css/jquery-ui.css?ver=4.4.6' type='text/css' media='all' /> <link rel='stylesheet' id='color-css' href='http://mysite.net/wp-content/themes/deals/css/color-orange.css?ver=4.4.6' type='text/css' media='all' /> <link rel='stylesheet' id='responsive-css' href='http://mysite.net/wp-content/themes/deals/css/responsive.css?ver=4.4.6' type='text/css' media='all' /> <link rel='stylesheet' id='custom-css' href='http://mysite='all' /> 

They are generated using the wp_head () function ;

The same with Javascript links.

How can I turn them all off with a header?

    2 answers 2

    These links are not superfluous once, without loading these styles, the theme will not work. All that can be done is to find the calls to enqueue_style in the subject and try to change one argument so that these styles load in the basement. But it is fraught, and, most likely, the topic will still stop working.

    There are no universal recipes for all occasions, so blindly follow the recommendations of PageSpeed ​​is not worth it. Google makes recommendations for the widest possible list of platforms, and what is good for one case is not always worth using in another.

    What do you need? Fast website or virtual PageSpeed ​​glasses? Most likely, the first. So from experience, I can tell you that these styles in the title have almost no effect on the speed of loading, and dolbo-days with them.

    Most often you need to compress images, reduce content size, compress styles and scripts, move away from ajax and iframe whenever possible, adjust caches, do everything on vps in the end, etc. etc.

    These things are real speed gains. And combing styles in the title - most often wasted time spent. Look at the waterfall in Pingdom and you will see where you have the main delays when loading the page.

      Through a call to remove_action you can remove unnecessary data to us:

       remove_action( 'wp_head', 'wp_generator' ); 

      Here is a list of everything that can be removed from the header:

       remove_action( 'wp_head', 'feed_links', 2 ); // Удаляет ссылки RSS-лент записи и комментариев remove_action( 'wp_head', 'feed_links_extra', 3 ); // Удаляет ссылки RSS-лент категорий и архивов remove_action( 'wp_head', 'rsd_link' ); // Удаляет RSD ссылку для удаленной публикации remove_action( 'wp_head', 'wlwmanifest_link' ); // Удаляет ссылку Windows для Live Writer remove_action( 'wp_head', 'wp_shortlink_wp_head', 10, 0); // Удаляет короткую ссылку remove_action( 'wp_head', 'wp_generator' ); // Удаляет информацию о версии WordPress remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 ); // Удаляет ссылки на предыдущую и следующую статьи // отключение WordPress REST API remove_action( 'wp_head', 'rest_output_link_wp_head' ); remove_action( 'wp_head', 'wp_oembed_add_discovery_links' ); remove_action( 'template_redirect', 'rest_output_link_header', 11, 0 ); // устаревшие функции // используйте только для WordPress до версии 3.2 включительно if ( get_bloginfo('version') <= '3.2' ) { remove_action( 'wp_head', 'adjacent_posts_rel_link', 10, 0 ); // Удаляет ссылки на предыдущую и следующую статьи remove_action( 'wp_head', 'index_rel_link'); // Удаляет ссылку на главную страницу remove_action( 'wp_head', 'parent_post_rel_link', 10, 0 ); // Удаляет ссылку на родительскую страницу remove_action( 'wp_head', 'start_post_rel_link', 10, 0 ); // Удаляет ссылку на первую запись } 
      • I had it all and I deleted it in this way already. But here are the links that I wrote above - Ector
      • @Ector are links to WP resources and plugins. I would advise it is better to demolish wp_head altogether and prescribe the connection of resources. I did this. - Vadizar
      • But are my links to css files generally required to be connected to the header? Simply if these connections are removed, then the site breaks down. - Ector
      • @Ector, therefore breaks. Listen to what KAGG Design says. The numbers in GoogleMill are nonsense for the most part . Want 100/100? Nothing is easier - 503 and no problems :) - SeVlad
      • @SeVlad to demolish CSS at the end of a body is really nonsense. And for the rest, you can listen. In any case, in any matters you need to think with your head. Not for each project, these tips fit. - Vadizar