Here is some instructions and code you can use for site speed optimizing which you can test here https://developers.google.com/speed/pagespeed/insights/?hl=en
- Install plugin Autoptimize and set next options:
- Install plugin WP Super Cache
- Install plugin Compress JPEG & PNG images
- Set your options here '/wp-admin/options-general.php?page=tinify'
- Install plugin Disable Embeds
- Install plugin Disable Emojis (GDPR friendly)
- Add next code in your current wordpress theme file functions.php:123456789101112131415161718192021222324add_filter('autoptimize_html_after_minify', function($content) {$site_url = 'https://YOUR_SITE_LINK_HERE';//do not set slash on the end$content = str_replace("", ' ', $content);$content = str_replace('', ' ', $content);$content = str_replace(" ", ' ', $content);$content = str_replace(' ', ' ', $content);$content = str_replace("rel='stylesheet preload' as='style'", "rel='stylesheet preload'", $content);$content = str_replace('rel="stylesheet preload" as="style"', 'rel="stylesheet preload"', $content);$content = str_replace('@font-face {font-display: swap; ', '@font-face {font-display: swap; font-display: swap;', $content);$content = str_replace('@font-face {font-display: swap; ', '@font-face {font-display: swap; font-display: swap;', $content);$content = str_replace("<img", "<img loading='lazy'", $content);$content = str_replace($site_url . '/wp-includes/js', '/wp-includes/js', $content);$content = str_replace($site_url . '/wp-content/cache/autoptimize', '/wp-content/cache/autoptimize', $content);$content = str_replace($site_url . '/wp-content/themes/', '/wp-content/themes/', $content);$content = str_replace($site_url . '/wp-content/uploads/', '/wp-content/uploads/', $content);$content = str_replace($site_url . '/wp-content/plugins/', '/wp-content/plugins/', $content);return $content;}, 9999, 1);
- Also it is possible to optimize jquery.js which is excluded in Autoptimize, but this way not always work, so check your site functionality after next:
- in your site current wp theme file functions.php add next code:1234//exlude jquery to print it in the header by file_get_contentsadd_action('wp_enqueue_scripts', function () {wp_deregister_script('jquery');});
- in your site current wp theme file functions.php add next code before <?php wp_head(); ?>:123<script><?php echo file_get_contents(ABSPATH . WPINC . '/js/jquery/jquery.js'); ?></script>
- in your site current wp theme file functions.php add next code:
- be care with jquery.js optimization
