Hier zijn enkele instructies en code die u kunt gebruiken voor het optimaliseren van de sitesnelheid, die u hier kunt testen https://developers.google.com/speed/pagespeed/insights/?hl=en
- Installeer plugin Autoptimize en stel de volgende opties in:
- Installeer plugin WP Super Cache
- Installeer plugin Comprimeer JPEG- en PNG-afbeeldingen
- Stel hier uw opties in '/wp-admin/options-general.php?page=tinify'
- Installeer plugin Embeds uitschakelen
- Installeer plugin Schakel Emoji's uit (AVG-vriendelijk)
- Voeg de volgende code toe aan uw huidige WordPress-themabestand 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);
- Ook is het mogelijk om te optimaliseren jquery.js die is uitgesloten in Autoptimize, maar deze manier werkt niet altijd, dus controleer de functionaliteit van uw site na het volgende:
- in het huidige wp-themabestand van uw site functions.php voeg volgende code toe:1234//exlude jquery to print it in the header by file_get_contentsadd_action('wp_enqueue_scripts', function () {wp_deregister_script('jquery');});
- in het huidige wp-themabestand van uw site functions.php voeg de volgende code eerder toe :123<script><?php echo file_get_contents(ABSPATH . WPINC . '/js/jquery/jquery.js'); ?></script>
- in het huidige wp-themabestand van uw site functions.php voeg volgende code toe:
- wees voorzichtig met jquery.js optimalisatie