Aqui estão algumas instruções e códigos que você pode usar para otimizar a velocidade do site, que você pode testar aqui https://developers.google.com/speed/pagespeed/insights/?hl=en
- Instalar plugin Autoptimize e definir as próximas opções:
- Instalar plugin WP Super Cache
- Instalar plugin Comprimir imagens JPEG e PNG
- Defina suas opções aqui '/wp-admin/options-general.php?page=tinify'
- Instalar plugin desativar Incorpora
- Instalar plugin Desativar Emojis (compatível com GDPR)
- Adicione o próximo código em seu arquivo de tema wordpress atual 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);
- Também é possível otimizar jquery.js que é excluído em Autoptimize, mas nem sempre funciona, então verifique a funcionalidade do seu site a seguir:
- no arquivo de tema wp atual do seu site functions.php adicione o próximo código:1234//exlude jquery to print it in the header by file_get_contentsadd_action('wp_enqueue_scripts', function () {wp_deregister_script('jquery');});
- no arquivo de tema wp atual do seu site functions.php adicione o próximo código antes :123<script><?php echo file_get_contents(ABSPATH . WPINC . '/js/jquery/jquery.js'); ?></script>
- no arquivo de tema wp atual do seu site functions.php adicione o próximo código:
- cuidado com jquery.js otimização
