<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Seamus P Leahy</title>
    <description>The latest articles on DEV Community by Seamus P Leahy (@seamusleahy).</description>
    <link>https://dev.to/seamusleahy</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1176367%2F9cc926c7-4779-4a6f-be2a-523b3a1b9f99.png</url>
      <title>DEV Community: Seamus P Leahy</title>
      <link>https://dev.to/seamusleahy</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/seamusleahy"/>
    <language>en</language>
    <item>
      <title>7 Tips for WordPress Dev from a Senior SWE</title>
      <dc:creator>Seamus P Leahy</dc:creator>
      <pubDate>Thu, 05 Oct 2023 18:09:56 +0000</pubDate>
      <link>https://dev.to/seamusleahy/7-tips-for-wordpress-dev-from-a-senior-swe-4089</link>
      <guid>https://dev.to/seamusleahy/7-tips-for-wordpress-dev-from-a-senior-swe-4089</guid>
      <description>&lt;p&gt;I didn't expect to be back developing in WordPress after nine years. I spent much of my time away from WordPress, working on large web apps. One web app was so large that they gave up on making it run locally.&lt;/p&gt;

&lt;p&gt;I was back with WordPress, specifically, to optimize &lt;a href="https://pagespeed.web.dev/" rel="noopener noreferrer"&gt;PageSpeed Insights&lt;/a&gt; performance. Here are my seven tips for WordPress developers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Table of Contents&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;1️⃣ Remove jQuery Migrate&lt;br&gt;
2️⃣ Use WebP Images in Your Theme&lt;br&gt;
3️⃣ Use Links When You Need A Link&lt;br&gt;
4️⃣ Minimize CSS with Tailwind&lt;br&gt;
5️⃣ Preload Important Assets&lt;br&gt;
6️⃣ Don't Do Client-Side Rendering&lt;br&gt;
7️⃣ Chrome Developer Tools&lt;/p&gt;


&lt;h2&gt;
  
  
  1️⃣ Remove jQuery Migrate
&lt;/h2&gt;

&lt;p&gt;WordPress loads the &lt;a href="https://github.com/jquery/jquery-migrate" rel="noopener noreferrer"&gt;jQuery Migrate&lt;/a&gt; JavaScript file on every page. You can likely remove it with no negative impact. When jQuery 2 was released ten years ago, it made changes that broke many existing scripts using jQuery, hence the reason for the jQuery Migrate script. Today, very few jQuery scripts require the migrate script (even with jQuery 3.x updates).&lt;/p&gt;

&lt;p&gt;You very likely don't need the jQuery Migrate script. So far, I've only found a single plugin that required the migrate script to not break. Stop making your users download a file that is of no use to anyone.&lt;/p&gt;
&lt;h3&gt;
  
  
  Can You Safely Remove jQuery Migrate?
&lt;/h3&gt;

&lt;p&gt;You could remove jQuery Migrate to see what breaks. A better alternative is to have jQuery Migrate tell you when it is required. The un-minified version of jQuery Migrate will report to the console anytime a deprecated method is used.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3qxvf9az0hmz5pyixtnr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3qxvf9az0hmz5pyixtnr.png" alt="jQuery migrate messages in console"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Set &lt;a href="https://wordpress.org/documentation/article/debugging-in-wordpress/#script_debug" rel="noopener noreferrer"&gt;&lt;code&gt;SCRIPT_DEBUG&lt;/code&gt;&lt;/a&gt; to true in your &lt;code&gt;wp-config.php&lt;/code&gt; so WordPress loads the non-minified version of jQuery Migrate and the other core JavaScript files.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nb"&gt;define&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="s1"&gt;'SCRIPT_DEBUG'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  How-to Disable jQuery Migrate
&lt;/h3&gt;

&lt;p&gt;You can remove either by code or with a plugin like &lt;a href="https://wordpress.org/plugins/remove-jquery-migrate/" rel="noopener noreferrer"&gt;Remove jQuery Migrate&lt;/a&gt; or via configurations of an optimization plugin like &lt;a href="https://wordpress.org/plugins/hummingbird-performance/" rel="noopener noreferrer"&gt;Hummingbird&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;dequeue_jquery_migrate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;$scripts&lt;/span&gt; &lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt; &lt;span class="nf"&gt;is_admin&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt; &lt;span class="k"&gt;empty&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;$scripts&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;registered&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'jquery'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nv"&gt;$scripts&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;registered&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'jquery'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;deps&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;array_diff&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="nv"&gt;$scripts&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;registered&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'jquery'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;deps&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="p"&gt;[&lt;/span&gt; &lt;span class="s1"&gt;'jquery-migrate'&lt;/span&gt; &lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nf"&gt;add_action&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="s1"&gt;'wp_default_scripts'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'dequeue_jquery_migrate'&lt;/span&gt; &lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  2️⃣ Use WebP Images in Your Theme
&lt;/h2&gt;

&lt;p&gt;Slim down the size of your theme images by switching from JPEGs and PNGs to WebP. &lt;a href="https://developers.google.com/speed/webp" rel="noopener noreferrer"&gt;WebP is a newer image format&lt;/a&gt; that is roughly 25% smaller while having the same features. If you are worried about browser support, &lt;a href="https://github.com/jquery/jquery-migrate" rel="noopener noreferrer"&gt;WebP is widely supported in browsers today&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F24t8708lkmbrfxfa5163.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F24t8708lkmbrfxfa5163.png" alt="Screenshot of caniuse for WebP"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  3️⃣ Use Links When You Need A Link
&lt;/h2&gt;

&lt;p&gt;Use &lt;code&gt;&amp;lt;a href&amp;gt;&lt;/code&gt; for linking to other pages. Don't use &lt;code&gt;&amp;lt;button&amp;gt;&lt;/code&gt;s with JavaScript to add a link. Don't add JavaScript to a &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; to make it a link. It hurts your SEO and delays the time to interact with the page. Most WordPress websites do not do this, but a surprising number do. Keep an eye out for it on a website you are developing on.&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/seamusleahy/embed/MWZqoQz?height=600&amp;amp;default-tab=html,result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;




&lt;h2&gt;
  
  
  4️⃣ Minimize CSS with Tailwind
&lt;/h2&gt;

&lt;p&gt;Optimize your custom WordPress website by using the &lt;a href="https://tailwindcss.com/" rel="noopener noreferrer"&gt;Tailwind CSS library&lt;/a&gt;. The hardship all websites face is endlessly growing CSS files. More CSS means more bytes to download and more effort the browser needs to keep track of all the CSS rules.&lt;/p&gt;

&lt;p&gt;One answer to this is utility-centric CSS instead of element-centric. The element-centric is what you are familiar with, where the selectors in your CSS-specific element, like the search bar or navigation items.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Example of element-centric CSS&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.primary-menu&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nt"&gt;li&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;inline-block&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;vertical-align&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;middle&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;white-space&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;nowrap&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Element-centris CSS used in HTML&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;ul&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"primary-menu"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&amp;lt;a&amp;gt;&lt;/span&gt;...&lt;span class="nt"&gt;&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Utility-centric inverses the selectors as they are not for the element but for a single style. To style an element, you add multiple classes to the element for each styling you want.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Example of utility-centric CSS&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.inline-block&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;inline-block&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nc"&gt;.align-middle&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;vertical-align&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;middle&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nc"&gt;.whitespace-nowrap&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;white-space&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;nowrap&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Utility-centric CSS used in HTML&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;ul&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;li&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"inline-block align-middle whitespace-nowrap”&amp;gt;&amp;lt;a&amp;gt;...&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It does increase the size of the HTML, but this is more than offset by the benefit of reducing the CSS blocking time; the &lt;a href="https://web.dev/critical-rendering-path-render-blocking-css/" rel="noopener noreferrer"&gt;browser pauses rendering the page while waiting to download and parse a CSS file&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Resources for using Tailwind CSS in WordPress:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;a href="https://css-tricks.com/adding-tailwind-css-to-wordpress-themes/" rel="noopener noreferrer"&gt;CSS-Tricks&lt;/a&gt; has a detailed article&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://wordpress.org/plugins/tailpress/" rel="noopener noreferrer"&gt;TailPress&lt;/a&gt; is a plugin to integrate Tailwind into WordPress&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  5️⃣ Preload Important Assets
&lt;/h2&gt;

&lt;p&gt;Add &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel/preload" rel="noopener noreferrer"&gt;&lt;code&gt;&amp;lt;link rel= "preload" href="…"&amp;gt;&lt;/code&gt;&lt;/a&gt; at the top of the &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt; for assets you want the browser to get to downloading right away. You don't want to put every asset for the page in a preload, just those you want to move to the front of the queue. Here are some recommended assets you may want to move to preload.&lt;/p&gt;

&lt;p&gt;Examples of assets to preload:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Primary CSS file&lt;/li&gt;
&lt;li&gt;  Icon font&lt;/li&gt;
&lt;li&gt;  Hero image&lt;/li&gt;
&lt;li&gt;  Background image&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It is beneficial for preloading assets that are loaded from other assets. For example, the browser without preload hints would have to download and parse the CSS before knowing the font files to download. With the preload hints, the browser can download the font files parallel to the CSS file.&lt;/p&gt;

&lt;h3&gt;
  
  
  Add Preloads in &lt;code&gt;header.php&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;In your theme's &lt;code&gt;header.php&lt;/code&gt; file, add the preload &lt;code&gt;&amp;lt;link&amp;gt;&lt;/code&gt; elements near the top of the &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt;. The preload hints should appear as soon as they can in the HTML. The only element it needs to be before is the &lt;code&gt;&amp;lt;meta charset="…"&amp;gt;&lt;/code&gt; as that must be the first element in the &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt;. I would recommend placing the viewport and title before the preloads if possible.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;!doctype html&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;html&lt;/span&gt; &lt;span class="cp"&gt;&amp;lt;?php&lt;/span&gt; &lt;span class="nf"&gt;language_attributes&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="cp"&gt;?&amp;gt;&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;charset=&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="cp"&gt;&amp;lt;?php&lt;/span&gt; &lt;span class="nf"&gt;bloginfo&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="s1"&gt;'charset'&lt;/span&gt; &lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="cp"&gt;?&amp;gt;&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"viewport"&lt;/span&gt; &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"width=device-width, initial-scale=1"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt; &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"preload"&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="cp"&gt;&amp;lt;?php&lt;/span&gt; &lt;span class="k"&gt;echo&lt;/span&gt; &lt;span class="nf"&gt;get_theme_file_uri&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="s1"&gt;'css/main.css'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="cp"&gt;?&amp;gt;&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt; &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"preload"&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="cp"&gt;&amp;lt;?php&lt;/span&gt; &lt;span class="k"&gt;echo&lt;/span&gt; &lt;span class="nf"&gt;get_theme_file_uri&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="n"&gt;fonts&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;icons&lt;/span&gt;&lt;span class="mf"&gt;.&lt;/span&gt;&lt;span class="n"&gt;woff&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="cp"&gt;?&amp;gt;&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="cp"&gt;&amp;lt;?php&lt;/span&gt; &lt;span class="nf"&gt;wp_head&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="cp"&gt;?&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Use a Plugin to Add Preloads
&lt;/h3&gt;

&lt;p&gt;Many optimization plugins support preloading assets. Some require manual configuration or additional services.&lt;/p&gt;

&lt;p&gt;Here are a few popular plugins:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;a href="https://getwpo.com/" rel="noopener noreferrer"&gt;WP-Optimize Premium&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://wp-rocket.me/" rel="noopener noreferrer"&gt;WP Rockets&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://wordpress.org/plugins/hummingbird-performance/" rel="noopener noreferrer"&gt;Hummingbird&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Use an Optimization Service for Preloads
&lt;/h3&gt;

&lt;p&gt;There are a handful of services that will process and optimize the HTML and assets for your WordPress website. They will automatically detect important assets and add the preload code to what is sent to your visitors.&lt;/p&gt;

&lt;p&gt;Here are a few popular services:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;a href="https://flyingpress.com/" rel="noopener noreferrer"&gt;FlyingPress&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://nitropack.io/" rel="noopener noreferrer"&gt;NitroPack&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  6️⃣ Don't Do Client-Side Rendering
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://web.dev/rendering-on-the-web/" rel="noopener noreferrer"&gt;Do server-side rendering for your website&lt;/a&gt;. You are very likely doing server-side rendering as it is the WordPress way. The easiest way to test is to disable JavaScript and reload the page. If you see the text content, your website is rendered on the server.&lt;/p&gt;

&lt;p&gt;Client-side rendering has its place. In fact, a lot of my work has been client-side rendering. It is a good choice for web apps while a poor choice for content websites.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Web Apps&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Social media: Facebook, Instagram, Twitter&lt;/li&gt;
&lt;li&gt;  Productivity: Google Docs, Microsoft 365, Trello&lt;/li&gt;
&lt;li&gt;  Banking accounts&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Content Websites&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Marketing&lt;/li&gt;
&lt;li&gt;  Blogs&lt;/li&gt;
&lt;li&gt;  Help Centers&lt;/li&gt;
&lt;li&gt;  News&lt;/li&gt;
&lt;li&gt;  Store products&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The two reasons for server-side rendering for content websites are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Users see the content faster, making them less likely to abandon the page.&lt;/li&gt;
&lt;li&gt;  Google's search bot can scan more of your website in the time it spends on your website.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  7️⃣ Chrome Developer Tools
&lt;/h2&gt;

&lt;p&gt;Learn how to use the diagnostic tools of Chrome's Dev Tools. Here are three features you can start using today.&lt;/p&gt;

&lt;h3&gt;
  
  
  Emulate Slow Networks
&lt;/h3&gt;

&lt;p&gt;Test your website with 3G emulated speeds. &lt;a href="https://pagespeed.web.dev/" rel="noopener noreferrer"&gt;Google's PageSpeed Insights&lt;/a&gt; defaults to 3G speeds for evaluating your website. These evaluations are believed to impact your SEO ranking in Google.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3t8slk480wiwq76yn8bt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3t8slk480wiwq76yn8bt.png" alt="Screenshot of setting network emulation"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; Open the Developer Tools&lt;/li&gt;
&lt;li&gt; Click on the Network tab&lt;/li&gt;
&lt;li&gt; Check "Disabled cache" and change "No throttling" to "Fast 3G"&lt;/li&gt;
&lt;li&gt; Reload the page&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Block Network Requests
&lt;/h3&gt;

&lt;p&gt;One of the easiest ways to troubleshoot which JavaScript or image file is slowing down the website is to block those network requests. This means Chrome will skip downloading the file.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; Open the Developer Tools&lt;/li&gt;
&lt;li&gt; Click on the Network Tab&lt;/li&gt;
&lt;li&gt; Find the file you want to block in the list&lt;/li&gt;
&lt;li&gt; Open the context menu on the file by right-clicking on the file's row&lt;/li&gt;
&lt;li&gt; Click on "Block request URL"
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F28l2gutncpzgche4sgj8.png" alt="Image description"&gt;
&lt;/li&gt;
&lt;li&gt; Reload the page&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;To remove the block on the URL:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; Open the "Run command"&lt;/li&gt;
&lt;li&gt; Type "show network request blocking" and click on the action of the same name
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fngd6ztnopsrt0u6lootv.png" alt="Image description"&gt;
&lt;/li&gt;
&lt;li&gt; From the bottom panel, you can remove the blocked URL
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx28ky69wt36wxd85bmdn.png" alt="Image description"&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Highlight Layout Shifts
&lt;/h3&gt;

&lt;p&gt;When optimizing the above-the-fold loading, you'll want to minimize the number of times the visual pieces move about as assets are loaded. An easy way to see this is with the Rendering panel. This works best when emulating 3G speeds.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; Open the Developer Tools&lt;/li&gt;
&lt;li&gt; Open the "Run command"&lt;/li&gt;
&lt;li&gt; Type "show rendering and click the action of the same name&lt;/li&gt;
&lt;li&gt; In the Rendering panel, check "Layout Shift Regions"
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F57fki84xodifydxpjxa5.png" alt="Image description"&gt;
&lt;/li&gt;
&lt;li&gt; Refresh the page&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;I hope this motley list of tips helps you level up your WordPress development skills.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;&lt;strong&gt;👋 Hi there! My name is Seamus Leahy, and I am a software engineer specializing in front-end web development. My ultimate goal is to use my skills to build a better world and to lift up those around me. If you want to work together, &lt;a href="https://www.linkedin.com/in/seamusleahy/" rel="noopener noreferrer"&gt;message me on LinkedIn&lt;/a&gt;.&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;




</description>
      <category>webdev</category>
      <category>wordpress</category>
      <category>performance</category>
    </item>
  </channel>
</rss>
