Como melhorar a velocidade e o desempenho de um site WordPress

Adoro o WordPress, mas ele não é perfeito por padrão.
As opções de temas e plugins são mais importantes do que nunca, pois alguns podem prejudicar o desempenho do site.
Você pode fazer muitas coisas para melhorar qualquer site WordPress, e esta postagem abordará apenas algumas dessas otimizações que você pode (espero) implementar imediatamente.
Escolha uma empresa de hospedagem web confiável
Escolher um host ruim pode ser prejudicial ao desempenho de um site.
Embora hospedar em um servidor compartilhado possa parecer a solução mais econômica, ela definitivamente apresenta seus problemas. Compartilhar esse servidor com outros sites (potencialmente) problemáticos pode monopolizar recursos compartilhados em detrimento dos seus.
Hospedagem não custa uma fortuna. Eu sempre aconselho você a escolher um provedor de hospedagem que não só tenha ótimas especificações de hardware (em um servidor dedicado, se o orçamento permitir), mas também compreenda WordPress e tenha um suporte técnico robusto. E procure provedores com cache em nível de servidor.
Não importa se seu site está em uma plataforma de hospedagem WordPress gerenciada, em um servidor LiteSpeed ou em uma hospedagem em nuvem escalável , sempre vale a pena fazer sua própria pesquisa e comparar algumas empresas antes de decidir.
Além disso, considere o quão otimizado para SEO esse host é. O WordPress tem uma página de hospedagem com algumas empresas recomendadas.
Otimize as configurações do servidor e use CDNs
Depois que o site estiver hospedado no servidor, há outras otimizações que você pode aplicar no nível do servidor.
Protocolos mais recentes como HTTP/3 e QUIC reduzem a latência, especialmente em dispositivos móveis.
Cloudflare e LiteSpeed oferecem suporte imediato para isso, mas ainda vale a pena verificar também as configurações do seu servidor.
Existem vários CDNs disponíveis, mas minha recomendação sempre foi usar o Cloudflare.
O plano gratuito oferece muitas otimizações, incluindo polimento de imagens, armazenamento em cache e compactação (habilite o armazenamento em cache em camadas para otimizar ainda mais essas solicitações).
Também recomendo a oferta de otimização automática de plataforma (APO), que custa US$ 5 por site, ou é gratuita com qualquer um dos planos pagos .
No Cloudflare, recomendo armazenar em cache tudo, exceto wp-admin e conteúdo dinâmico, disponibilizar conteúdo obsoleto enquanto revalida o cache em segundo plano e usar os serviços do Web Application Firewall (WAF) que ajudam a bloquear ataques e limitar rastreadores.
Desabilitar XML-RPC
Existem várias otimizações para remover e limitar recursos que são habilitados por padrão no núcleo do WordPress.
Uma boa recomendação aqui seria desabilitar o XML-RPC se não for necessário:
Desabilitar XML-RPC
add_filter('xmlrpc_enabled', '__return_false');
Implementar técnicas de cache e compressão
In addition to server optimizations, you can implement further performance enhancements by adding caching and compression elements directly.
Using object caching such as Varnish or Redis can provide great results, as well as setting proper cache-control headers within.htaccess (Apache) or nginx.conf:
<FilesMatch "\.(css|js|jpg|png|gif|woff2|ttf|svg|ico)$">
Header set Cache-Control "max-age=31536000, public" FilesMatch>
Optimize Asset Loading
When caching and compression are in place, you can then take further steps to defer JavaScript.
For example:
<script src="script.js" defer>script>
Also, try to have any scripts load asynchronously so that they don’t degrade initial page load times.
When it comes to CSS, it’s always good to remove any unused styles where possible, although I wouldn’t say this is the biggest priority compared to other recommendations in this post.
Also, try to preload and pre-connect fonts for text that appears above the fold (custom fonts for the text in the footer doesn’t need to be preloaded) and other external resources where possible.
Here is an example of how this can be done:
<link rel="preload" as="font" href="fonts/myfont.woff2" type="font/woff2" crossorigin="anonymous">
Close Other Performance Gaps
If you’re a perfectionist like me, there’s always room for more optimizations.
- Enable lazy loading for images where possible and replace YouTube embeds with static image previews.
- Use Screaming Frog to detect unnecessary redirects.
- Close redirect loops and chains, which are reported within Semrush site audits. Update internal links to point directly to the final destination URL.
- Reduce third-party requests where possible. For example, load Google Analytics or Google Fonts locally instead of via external scripts.
- Disable unused social media widgets and embeds.
Choose The Right Themes & Plugins
So, you have your hosting account set up and your WordPress site installed.
However, the abundance of choices you have when it comes to themes and plugins makes it hard to decide and choose trusted developers. This is a challenge that has always been present, and I have been writing about it since 2013 at least.
When choosing both themes and plugins, consider the following when doing so:
- Is the theme compatible with the most recent versions of WordPress?
- Does it adhere to WordPress best practices for theme and plugin development? You can check this using the Theme Check plugin for themes and the Plugin Check for plugins.
- Does the author of the theme have developer E-E-A-T? Can you trust them?
- Ensure there isn’t too much code bloat. The more a theme is generalized to the masses (e.g., “all-in-one themes for any business”), the more it will have to be developed to accommodate the widest of audiences. The more bespoke the theme, (presumably) the less of a chance of code bloat.
- Read reviews and investigate support offerings. For themes and plugins offered within WordPress’s own repo, some reviews and ratings are always helpful to inform your decisions.
Most themes offer live previews, so it’s worth running those URLs through speed testing tools such as PageSpeed Insights, Web Page Test, and Chrome DevTools.
Apply Some WordPress-Specific Optimizations
Still not done with my perfectionism! Here are some recommendations on WordPress.
The WP Heartbeat API can create unnecessary AJAX requests. Reduce its frequency or disable it:
add_action( 'init', function() { wp_deregister_script('heartbeat'); });
You can also limit post-revisions and revision time intervals in wp-config.php:
define('WP_POST_REVISIONS', 5); define('AUTOSAVE_INTERVAL', 300); // 5 minutes
Disabling unused Gutenberg block CSS is also recommended if not needed:
add_filter('use_block_editor_for_post', '__return_false');
Use Recommended Plugins
With so many plugins available today, it seems daunting to know which ones are the best and most trusted.
Of course, “it depends” comes into play again, but generally, I advise using as few plugins as possible.
If you can solve some issues away from a plugin (e.g., server-level), then do that first.
Depending on what optimizations you may have set up elsewhere, some of these plugins may be unnecessary to install, but if not, it’s always good to know preferable options.
- Caching and compression: Autoptimize, W3 Total Cache, or Jetpack alongside WP Super Cache and Jetpack Boost.
- Preloading: instant.page is a great recommendation here. Uses one line of code that you can implement or they offer a WordPress plugin that does the same.
- Script deferring: Some plugins above offer this, but I personally use WP Meteor.
- Image optimization: TinyPNG or Smush for image compression, WebP express for serving WebP images over PNG/JPG/EPS. For further optimization, use Edge Images for utilizing edge transformation services to
markup.
- SEO: While not directly connected to improving speed, Yoast SEO optimizes a site’s visibility performance [disclosure, I work for Yoast]. Most of these features provided in the free version help with this, but things such as IndexNow are included within Premium. However, if you want to enable IndexNow without Premium, Bing offers its own plugin.
When installing any plugin, it’s always good to look at all settings properly and disable anything that is unnecessary to save more processing time and reduce code bloat.
To take this to the next level, you may also want to install Plugin Organizer, which allows you to set conditions for plugins to load only within relevant pages/areas of the site.
Monitor Your Server
Lastly, it’s always good to have a good monitoring system, such as New Relic, on the server.
Este sistema permite que você diagnostique e corrija quaisquer problemas que possam estar prejudicando o desempenho do site ou do servidor, além de reduzir ainda mais a carga desnecessária do servidor desabilitando módulos PHP não essenciais.
Você também pode configurar o registro para consultas lentas no MySQL:
SET GLOBAL slow_query_log = 'ON'; SET GLOBAL long_query_time = 1;
Também recomendo o plugin Query Monitor. Ou instalar o Blackfire para detectar trechos de código ineficientes que causam lentidão na resposta do servidor. É pago, mas altamente recomendado para empresas.
Os registros de erros também são sempre seus amigos ao diagnosticar outros problemas.
O WordPress também oferece modo de depuração, que é extremamente útil para diagnosticar problemas potenciais adicionando o seguinte em wp-config.php:
Observação: isso nunca deve ser habilitado em um site de produção ao vivo, pois pode expor informações confidenciais. Use apenas em preparação.
// Enable WP_DEBUG mode define( 'WP_DEBUG', true ); // Enable Debug logging to the /wp-content/debug.log file define( 'WP_DEBUG_LOG', true );
Conclusão: Melhore o desempenho do WordPress preservando a funcionalidade
Como você pode ver, há muita coisa que se pode fazer para melhorar um site WordPress, e é importante fazer isso de vários ângulos.
Faça o máximo que puder acima, garantindo que o site funcione como deveria.
Teste tudo primeiro para garantir que tudo o que você precisa esteja implementado corretamente e não atrapalhe outras funções do site (por exemplo, às vezes, armazenar em cache ou compactar JavaScript pode criar irregularidades ou impedir o funcionamento de alguns elementos do site) ou gerar outros conflitos. E então implante!