completefrontend
Open lab My progress
THE WEB PERFORMANCE FIELD GUIDE

CMS and e-commerce platforms

Speed up a WordPress or Shopify store you didn't write: find what each plugin and app adds, load app scripts without blocking, and use the platform's cache.

By the end, you can
  • 01
    Find who added each fileTrace every script and stylesheet on a platform page back to the theme or plugin that asked for it, and remove what the page doesn't use.
  • 02
    Load apps without blocking the pageTell a pasted script tag from an app block or an async script, and measure what each one costs the first paint.
  • 03
    Use the platform, and know its limitsPut a page cache and a CDN to work, know what they can't speed up, and tell what you can change on WordPress and on Shopify.

Kiran's Mint tea page, built from other people's code

Module 36 looked at speed through each framework's own tools. This last lesson looks at platforms: ready-made systems that run a whole site for you. WordPress and Shopify are the best known.

Ravi's cousin Kiran sells his teas in her town. She built her shop in a weekend, on WordPress with WooCommerce, its shop plugin. She picked a theme for the look. She added plugins for a wishlist heart, size buttons and a contact form. She didn't write a line of code.

Asha opens Kiran's Mint tea page on her phone. The screen stays blank. Then the words appear, but no photo. The photo comes last. Here is Asha's screen, second by second, before and after the fixes in this lesson:

Real frames of Kiran's Mint tea page on Asha's phone at 1, 2, 3 and 4 seconds. Before: 1 s is blank, 2 s is blank, 3 s shows the words, no photo, 4 s shows the page with its photo; first byte 2,489 ms, photo 3,692 ms. After: 1 s shows the words, no photo, 2 s shows the page with its photo, 3 s shows the page with its photo, 4 s shows the page with its photo; first byte 355 ms, photo 1,292 ms.1 s2 s3 s4 sBeforeBlankBlankBefore, at 3 s: the words, with no photo yetBefore, at 4 s: the Mint tea page with its photoFirst byte 2,489 ms. Photo 3,692 ms.AfterAfter, at 1 s: the words, with no photo yetAfter, at 2 s: the Mint tea page with its photoAfter, at 3 s: the Mint tea page with its photoAfter, at 4 s: the Mint tea page with its photoFirst byte 355 ms. Photo 1,292 ms.
Real frames from the course's recording. Before Kiran's fixes, the screen stayed blank for over two seconds, and the photo came after three. After them, the words were there within a second.

Kiran didn't write this code. So can she fix it? Mostly, yes. The course timed both versions:

Asha's two visits to Kiran's Mint tea pagePop out in the code editor (opens in a new tab)JavaScript
// Asha's visits to Kiran's Mint tea page. Times in ms after she asked for it.// JavaScript in kB, as it came over the network, compressed (1 kB = 1,000 bytes).const before = { firstByte: 2489, photo: 3692, javascript: 416.5, requests: 58 };const after = { firstByte: 355, photo: 1292, javascript: 130.4, requests: 39 }; for (const [name, visit] of [["Before", before], ["After", after]]) {  console.log(`${name}: first byte ${visit.firstByte} ms, photo ${visit.photo} ms, ${visit.javascript} kB of JavaScript, ${visit.requests} requests`);}
  • Lines 1 and 2 are comments. A millisecond (ms) is a thousandth of a second. A kB is 1,000 bytes. Compressed means the size as the file travels over the network.
  • Line 3 is the page as Kiran set it up. Line 4 is the same page after her fixes.
  • Line 7 prints Before: first byte 2489 ms, photo 3692 ms, 416.5 kB of JavaScript, 58 requests. Then it prints the same line for After.

The photo came 2,400 ms sooner. The page brought 286 kB less JavaScript. Yet Kiran changed no code in WordPress, WooCommerce or her theme. She changed what was on the page, and who answered it. After her fixes, a page cache answered Asha: a stored copy of the finished page, so WordPress didn't have to build it again. Why it matters: on a platform, you rarely rewrite code. You choose what runs, and where it comes from.

Real-life analogyA furnished flat

Kiran rents a furnished flat. The building and the furniture came with it, and she plugged in a few gadgets of her own. Her electricity bill is high. She can't rebuild the walls. But she can find which gadget uses the most power, unplug the ones she never uses, and ask about the boiler.

In real life: The building
In JavaScript: The platform: WordPress and WooCommerce, or Shopify
In real life: The furniture that came with the flat
In JavaScript: The theme: the page's look, and its own files
In real life: The gadgets she plugged in
In JavaScript: Plugins and apps, each adding its own files
In real life: The landlord's boiler
In JavaScript: The server and its caches
The main idea

On a platform, most of the code on your page was written by others: the platform, the theme, and every plugin or app. You make it fast by finding who added each file, keeping only what the page needs, and letting the platform's caches answer for you. The next four sections take one part each.

How the course recorded it

  • Kiran's shop: real WordPress 7.1.4, WooCommerce 11.3.0, the Astra theme 4.14.3, and three plugins from wordpress.org: Contact Form 7, YITH WooCommerce Wishlist, and Variation Swatches for the size buttons.
  • Running it: WordPress Playground's command line, version 3.1.64, ran the shop on the course's laptop. Playground runs PHP inside WebAssembly, with SQLite as the database. That's slower than a normal host. So its server times show that WordPress built a page, not how fast a host would.
  • Asha's phone: Chrome 157, with the CPU 4 times slower, on Lighthouse's phone screen. The course's server played a Fast 4G line: 3 round trips to open each new connection, then 165 ms before each answer, then 8.1 megabits a second.
  • Four versions: the page as Kiran set it up, the page after her fixes with a page cache, and two more with a review app added two ways. A small plugin of the course's switched between them for each visit.
  • Real input: Asha's tap on Add to cart was a mouse press and release, sent through Chrome's DevTools protocol, one second after the photo appeared.
  • 5 visits of each version, taking turns. The lesson quotes the visit with the middle LCP, unless it says otherwise.

Themes and plugins add files to every page

WordPress builds each page with PHP, a language that runs on the server. A theme decides how the page looks: its templates and its CSS. A plugin adds a feature, like a shop or a form. Both can add files to the page. Here is how a plugin adds a script, in its simplest form:

How a plugin adds its scriptPHP
<?php// A plugin's main file runs on every request.add_action('wp_enqueue_scripts', function () {  wp_enqueue_script('contact-form', plugins_url('form.js', __FILE__));});
  • Line 2 is a comment. WordPress runs every active plugin's main file on every request.
  • Line 3 hooks into wp_enqueue_scripts. That's the moment WordPress collects the files for a page.
  • Line 4 calls wp_enqueue_script. It puts form.js on the list, and WordPress prints a script tag for it.

Nothing here asks whether the page has a form. So the script goes on every page. Contact Form 7's docs say it works this way: "In its default settings, Contact Form 7 loads its JavaScript and CSS stylesheet on every page."

Real-life analogySide dishes on every table

A restaurant has a few cooks. Each cook has a side dish, and a rule: put mine on every table. So every table gets bread, soup and salad, even the one that only ordered tea. The tables fill up, and the tea takes longer to arrive.

In real life: A cook's side dish
In JavaScript: A plugin's script or stylesheet
In real life: The rule "on every table"
In JavaScript: wp_enqueue_script with no check for the page
In real life: The table that only ordered tea
In JavaScript: The Mint tea page, which has no form
In real life: "Only when someone orders it"
In JavaScript: Loading a plugin's files only on pages that use them

Who asked for each file?

To find out, the course asked WordPress itself. A small plugin listed every script and stylesheet WordPress printed for the Mint tea page, with the files each one needs. Then each file could be traced back to the theme or plugin that asked for it. Here is the JavaScript, by who asked:

The JavaScript on Kiran's Mint tea page before her fixes, compressed, by who asked for it: Wishlist plugin 277.5 kB, Shared by two or more 70.6 kB, WooCommerce 41.3 kB, Contact Form 7 8.5 kB, WordPress itself 6.7 kB, Astra theme 6.3 kB, Size buttons plugin 5.5 kB. Wishlist plugin and Contact Form 7 are gone after the fixes.JavaScript, compressed, by who asked for itWishlist plugin277.5 kBShared by two or more70.6 kBWooCommerce41.3 kBContact Form 78.5 kBWordPress itself6.7 kBAstra theme6.3 kBSize buttons plugin5.5 kB
Each bar is the JavaScript one owner asked for, to scale: a plugin, the theme, WordPress itself, or two or more together. Files from WordPress's own library count for whoever asked. The two shaded bars are gone after Kiran's fixes.

The wishlist heart asked for 277.5 kB of the 416.5 kB. That's two thirds of the page's JavaScript. Its button is built with React and a toolkit of its own. So WordPress also sent React, ReactDOM, Lodash and Moment from its own library. And on every page view, the button asked WordPress for wishlists twice. It used WordPress's REST API, the way scripts ask WordPress for data. Each of those calls ran PHP too. Why it matters: one small feature can bring a whole framework with it. Measure a plugin before you decide it's cheap.

Pick a theme or plugin to see its files:

Playground: whose files are on Kiran's page?
Wishlist plugin: its scripts and stylesheets
  1. JavaScript files10
  2. JavaScript, compressed277.5 kB
  3. CSS files4
  4. CSS, compressed12.8 kB
  5. The filesdist/deprecated.min.js, vendor/moment.min.js, dist/date.min.js, vendor/lodash.min.js, vendor/react.min.js, date/index.js, styles/index.js, components/index.js, vendor/react-dom.min.js, add-to-wishlist/index.js, css/jquery.selectBox.css, css/prettyPhoto.css, css/style.css, frontend/add-to-wishlist.css
  6. After Kiran's fixesGone
Try it yourself
Wishlist plugin: its scripts and stylesheets

Pick a theme or plugin. You see the scripts and stylesheets it asked for on the Mint tea page, as Kiran first set it up, and whether they were still there after her fixes.

From the course's recording in Chrome 157: the files that came before Asha's tap, from the visit the lesson keeps. A file two or more of them asked for is counted as shared. Sizes are compressed, as they came over the network.

Kiran's two fixes

First, the wishlist. Hardly anyone used it, so Kiran deactivated the plugin on WordPress's Plugins screen. Its files and its calls went with it. Second, the contact form. She still wants it, but on the contact page only. Contact Form 7 has a switch for that:

Contact Form 7's files, on the contact page onlyPHP
<?phpadd_filter('wpcf7_load_js', '__return_false');add_filter('wpcf7_load_css', '__return_false');add_action('wp_enqueue_scripts', function () {  if (is_page('contact')) {    wpcf7_enqueue_scripts();    wpcf7_enqueue_styles();  }});
  • Lines 2 and 3 use the plugin's own filters, wpcf7_load_js and wpcf7_load_css. A filter is a hook that lets your code change a value before WordPress uses it. Returning false turns the files off on every page.
  • Lines 4 to 9 put them back on one page. Line 5 checks for the page called contact. Lines 6 and 7 ask for the form's script and stylesheet.

A plugin without its own switch can still be limited. wp_dequeue_script and wp_dequeue_style take a file off the list, by its handle: the name the plugin gave it in WordPress.

After both fixes, the page had 27 JavaScript files instead of 39: 130.4 kB instead of 416.5 kB. Its CSS went from 49.8 kB to 35.6 kB.

What WordPress already does for you

Not everything needs fixing. Here is the photo's tag, as WordPress printed it:

The photo's tag, one attribute per lineHTML
<img  src=".../mint-tea-600x400.jpg"  width="600" height="400"  srcset="... 600w, 300w, 1024w, 768w, 1536w, 1600w"  sizes="(max-width: 600px) 100vw, 600px"  fetchpriority="high"  decoding="async"  alt="Mint tea">
  • Line 3 gives the photo's width and height, so its space is kept before it arrives.
  • Line 4 is srcset: the photo in six widths. WordPress and WooCommerce made the smaller ones when Kiran uploaded it. The 1600 px one is her original. Line 5, sizes, tells the browser how wide the photo will be shown. Asha's phone picked the 768 px file: 19.3 kB.
  • Line 6 is fetchpriority="high". Since WordPress 6.3, WordPress adds it to the image it thinks will be the LCP. Chrome then asks for it early.

Scripts too. WordPress 6.3 added a strategy setting to wp_enqueue_script, for defer or async. WooCommerce uses it: 10 script tags on Kiran's page had defer. And since WordPress 6.9, WordPress loads the CSS of only the blocks a page uses, even with a classic theme like Astra.

One download the fixes missed

Look at the photo files the page downloaded. Both versions downloaded two of them. One was the 768 px photo Asha saw. The other was the full 1600 px original: 102.8 kB, more than five times bigger. The gallery's zoom asked for it, so it can show the photo large.

The zoom's switch, and the line that turns it offPHP
// WooCommerce: is the gallery's zoom on? The theme decides.'zoom_enabled' => apply_filters('woocommerce_single_product_zoom_enabled', get_theme_support('wc-product-gallery-zoom')), // A line in a small plugin of Kiran's: no zoom, so no full-size photo.add_filter('woocommerce_single_product_zoom_enabled', '__return_false');
  • Line 2 is from WooCommerce 11.3.0, line 653. The zoom is on when the theme says it supports zoom. Astra says it does.
  • Line 5 is a filter that turns the zoom off. WooCommerce's gallery script then skips the zoom, and its download.

Why it matters: a theme can switch on features you never asked for. Check every image request, not only the images you can see.

Apps and injected scripts

Shopify calls its add-ons apps. Many plugins and apps add a script that comes from another company's server. That's a third party, like the tags in lessons 24.1 to 24.3. What changes is how the script gets into the page.

Kiran tries a review app. It shows the stars under the tea's name. Its install guide says: paste this tag at the top of your theme's head. On WordPress, that takes a few lines:

The review app, pasted at the top of the headPHP
<?phpadd_action('wp_head', function () {  echo '<script src="https://apps.example/star-reviews.js"></script>';}, 1);
  • Line 2 hooks into wp_head, where WordPress prints the head. The 1 on line 4 makes it run early, so the tag lands near the top.
  • Line 3 prints a plain script tag.

The other way asks WordPress for the same file, with the async strategy:

The same app, enqueued with asyncPHP
<?phpadd_action('wp_enqueue_scripts', function () {  wp_enqueue_script('star-reviews', 'https://apps.example/star-reviews.js', array(), null, array('strategy' => 'async'));});

Line 3 adds array('strategy' => 'async'). Here are the two tags WordPress printed:

The two tags in the pageHTML
<!-- Pasted at the top of the head: -->
<script src="https://apps.example/star-reviews.js"></script>

<!-- Enqueued with the async strategy: -->
<script async data-wp-strategy="async" id="star-reviews-js" src="https://apps.example/star-reviews.js"></script>

Line 2 is the pasted tag. Line 5 is WordPress's: the same file, with async. A plain script tag stops the browser. It can't read the rest of the HTML until the script has arrived and run. async lets it keep reading, and the script runs whenever it arrives. And this script lives on another server, so Asha's phone must open a new connection first.

Real-life analogyWaiting for the delivery van

A shop opens at nine. One morning the owner says: we don't open until the van from the next town arrives. Customers wait at the locked door. The next day she opens at nine, and unpacks the van whenever it comes.

In real life: The locked door
In JavaScript: The page, which can't paint yet
In real life: The van from another town
In JavaScript: The app's script, from the app's own server
In real life: "Not until the van arrives"
In JavaScript: A plain script tag at the top of the head
In real life: Unpacking whenever it comes
In JavaScript: async: the script runs when it arrives
The review app's script and the page's first paint, to scale, the middle of five visits each. Blocking: the script from 360 ms to 716 ms, first paint at 904 ms, photo at 1,380 ms. Async: the script from 383 ms to 1,040 ms, first paint at 744 ms, photo at 1,244 ms.BlockingApp's scriptfirst paint 904 msphoto 1,380 msAsyncApp's scriptfirst paint 744 msphoto 1,244 ms0500 ms1000 ms1500 ms
Each bar is the app's script, from Chrome asking for it to its last byte. With the plain tag, the first paint waited for the script. With async, the page painted first, and the script came after.
The review app's script, two waysPop out in the code editor (opens in a new tab)JavaScript
// The review app's script, two ways. The middle of five visits each, in ms.const blocking = { scriptArrived: 716, firstPaint: 904, photo: 1380 };const nonBlocking = { scriptArrived: 1040, firstPaint: 744, photo: 1244 }; console.log(`Blocking: first paint ${blocking.firstPaint} ms, photo ${blocking.photo} ms`);console.log(`Async: first paint ${nonBlocking.firstPaint} ms, photo ${nonBlocking.photo} ms`);console.log(`The wait for the script: ${blocking.firstPaint - nonBlocking.firstPaint} ms`);
  • Line 2 is the pasted tag. Line 3 is async. Each holds the middle of five visits.
  • Lines 5 to 7 print Blocking: first paint 904 ms, photo 1380 ms, Async: first paint 744 ms, photo 1244 ms and The wait for the script: 160 ms.

With the pasted tag, the first paint waited 160 ms longer, and the photo 136 ms. It wasn't luck: the slowest async visit painted at 884 ms, before the fastest blocking visit, at 904 ms. The stars came at about the same time either way, because the app asks its server for the reviews only once the HTML has been read. Why it matters: one tag at the top of the head made every visitor wait before anything appeared. A slower app server makes the wait longer.

Apps on Shopify

Shopify gives apps two ways in. The old one is Shopify's ScriptTag API, which isn't the HTML tag: the app asks Shopify to add its script to the store's pages. Shopify's docs say these scripts "load independently of theme control", and advise: "Ask the app developer to use defer if a script blocks rendering." Shopify has now deprecated the ScriptTag API.

The new way is theme app extensions:

  • An app block is a part of the page that the store owner adds, moves or removes in the theme editor.
  • An app embed block can add a script with nothing to see. Shopify adds it "by adding a <script async> tag in the <head>", and only on pages where the block is on.
  • When the app is uninstalled, its blocks are "automatically and entirely removed". An app that pasted code into theme files can leave it behind.

Shopify also sets a limit for apps with its Built for Shopify badge: "Your app must not reduce the storefront Lighthouse performance score by more than ten points." Why it matters: on any platform, ask how an app loads its script before you install it, and measure the page after.

Pick a version to see all four side by side:

Playground: four versions of Kiran's page
Before: Asha's visit
  1. Who answered the pageWordPress, with PHP
  2. First byte2,489 ms
  3. First paint2,988 ms
  4. First paint, middle of five visits2,988 ms
  5. The photo, the LCP3,692 ms
  6. JavaScript, compressed416.5 kB
  7. CSS, compressed49.8 kB
  8. Requests before the tap58
  9. Tap to the next paint13.7 ms
  10. Tap to the next page3,730 ms
Try it yourself
Before: Asha's visit

Pick a version. Asha opened the Mint tea page, and tapped Add to cart a second after the photo appeared.

From the course's recording in Chrome 157, with the CPU slowed 4 times on an imitated Fast 4G line. Times are in ms after Asha asked for the page, or after her tap, from the visit with the middle LCP of 5. One row gives the middle first paint of all 5.

Platform caching and CDNs

Back to the first byte. Before the fixes, it came at 2,489 ms. WordPress built the page from scratch for every visit: PHP ran the theme and every plugin, and read the database. A page cache keeps a copy of the finished page. The next visitor gets the copy, and PHP doesn't run at all. Many hosts run one in front of WordPress, and caching plugins do the same job.

Real-life analogyLoaves on the bakery shelf

A bakery bakes its bread before it opens, and puts the loaves on the shelf. A customer takes one and pays. Nobody waits for the oven. But a birthday cake with a name on it is baked to order, every time.

In real life: Baking a loaf
In JavaScript: PHP building the page
In real life: The loaves on the shelf
In JavaScript: The page cache's copies
In real life: Taking a loaf and paying
In JavaScript: A visit the cache answers
In real life: A birthday cake with a name on it
In JavaScript: A page with one visitor's cart in it
Who answered Asha, and whenPop out in the code editor (opens in a new tab)JavaScript
// Asha's first byte, in ms. "built" is how long WordPress worked on the page.const before = { answeredBy: "WordPress", built: 2321, firstByte: 2489 };const after = { answeredBy: "the page cache", built: 0, firstByte: 355 }; for (const visit of [before, after]) {  console.log(`${visit.answeredBy}: built in ${visit.built} ms, first byte at ${visit.firstByte} ms`);}
  • Line 2 is the first version: WordPress worked 2,321 ms on the page.
  • Line 3 is after the fixes: a page cache in front of WordPress answered.
  • Line 6 prints WordPress: built in 2321 ms, first byte at 2489 ms and the page cache: built in 0 ms, first byte at 355 ms.

Remember, Playground is slower than a real host. So read the gap, not the 2,321 ms. With the cache, no PHP ran. The first byte came as soon as Asha's connection was open and the answer had crossed her network. Why it matters: on a slow server, a page cache is often the biggest single fix. WordPress's Site Health screen checks for one. It also times the server, and counts an answer under 600 ms as good (class-wp-site-health.php, line 3744).

What a cache can't answer

Then Asha taps Add to cart. That isn't a page view. It sends a POST, a request that changes something: here, her cart. No cache may answer a POST. WooCommerce's docs also say to keep the Cart, Checkout and My Account pages out of the cache, and visitors with cookies like woocommerce_items_in_cart. Once Asha has a cart, her later page views skip the cache too.

After Kiran's fixes. Asha's phone asks for the Mint tea page; the page cache answers with its copy, and the first byte arrives at 355 ms. Her tap on Add to cart sends a POST, which the page cache passes on to WordPress, PHP and SQLite; the next page arrives 2,399 ms after the tap.PhoneAshaPage cacheWordPressPHP and SQLiteGET pagecopy: 355 msPOST Add to cartThe next page came 2,399 ms after the tap
The page cache answered the page with a copy. Asha's tap on Add to cart was a POST, so it went past the cache to WordPress, every time.

Here is the rule the course's page cache followed, shortened to its two tests:

May the page cache answer?Pop out in the code editor (opens in a new tab)JavaScript
// May the page cache answer this request?function fromCache(request) {  if (request.method !== "GET") return false;  return !request.cookies.includes("woocommerce_items_in_cart");} console.log(fromCache({ method: "GET", cookies: "" }));console.log(fromCache({ method: "POST", cookies: "" }));console.log(fromCache({ method: "GET", cookies: "woocommerce_items_in_cart=1" }));
  • Line 3 sends anything but a GET to WordPress.
  • Line 4 does the same for a GET from a visitor with a cart.
  • Lines 7 to 9 print true, false and false.

WooCommerce answered the POST with the Mint tea page again, with a notice: Mint tea has been added to your cart. So how long did Asha wait for that next page?

Asha's tap, and the next pagePop out in the code editor (opens in a new tab)JavaScript
// From Asha's tap on Add to cart, in ms: to the next paint, and to the next page.const before = { tap: 13.7, nextPage: 3730 };const after = { tap: 11.6, nextPage: 2399 }; console.log(`Before: the tap painted in ${before.tap} ms, the next page came at ${before.nextPage} ms`);console.log(`After: the tap painted in ${after.tap} ms, the next page came at ${after.nextPage} ms`);
  • Line 2 is before the fixes. Line 3 is after. Both count from the tap.
  • Line 5 prints Before: the tap painted in 13.7 ms, the next page came at 3730 ms.
  • Line 6 prints After: the tap painted in 11.6 ms, the next page came at 2399 ms.

The tap itself was quick both times, far inside INP's 200 ms (lesson 26.1). By then the page's scripts had finished. The wait was the next page, built by PHP every time. Before the fixes, it waited longer. When the tap's request came, three other PHP requests were still running: the wishlist's two calls, and the tab's icon. The course's WordPress ran two PHP requests at a time, so the tap's request waited its turn. Why it matters: a page cache speeds up pages, not carts. Keep the PHP work on every request small.

CDNs, and what the platforms do for you

A CDN keeps copies of files on servers around the world, close to visitors (lesson 15.4). On WordPress, you add one yourself. WordPress's handbook says some CDNs also cache whole pages, which it calls "Full Page Caching (FPC) or Edge Caching".

Shopify does this for every store. Its docs list:

  • a CDN "backed by Cloudflare", with files compressed with Brotli and gzip, sent over HTTP/3;
  • a server built only to render store pages, the Storefront Renderer;
  • HTML sent in two parts, so the browser can start on the head early;
  • 103 Early Hints for the files the head needs;
  • speculation rules, which let the browser fetch a page before the visitor gets there.

WordPress now adds one of these to most sites too. Since WordPress 6.8, it adds speculation rules that fetch a link's page as a visitor starts to click it. Kiran's page had them. They're on only for visitors who aren't logged in, on sites with readable addresses like /product/mint-tea/ (speculative-loading.php, lines 26 to 28).

The platforms in the field

So which platform is fastest for real visitors? HTTP Archive's Technology Report looks at millions of sites. It finds which platform each site runs on, and joins that with CrUX, Chrome's field data (lesson 10.1). A site is good for a metric when at least 75% of its visits were good.

Good TTFB on phones, three platformsPop out in the code editor (opens in a new tab)JavaScript
// HTTP Archive's Technology Report, phones: [sites with a good TTFB, sites measured].const ttfb = {  WordPress: [570682, 2413384],  WooCommerce: [64186, 500596],  Shopify: [373779, 437688],}; for (const [platform, [good, measured]] of Object.entries(ttfb)) {  console.log(`${platform}: ${((good / measured) * 100).toFixed(1)}% of ${measured.toLocaleString("en")} sites`);}
  • Lines 3 to 5 hold, for each platform, the sites with a good TTFB and the sites measured, on phones.
  • Line 9 prints one line for each: WordPress: 23.6% of 2,413,384 sites, then the same for WooCommerce and Shopify.

Only 12.8% of WooCommerce sites had a good TTFB, against 85.4% of Shopify sites. Every Shopify store gets Shopify's servers and cache. A WordPress site gets whatever its owner set up. For all three Core Web Vitals, 49.0% of WordPress sites passed, 40.6% of WooCommerce sites, and 76.5% of Shopify sites. Why it matters: these are shares of many sites. Your own numbers depend on your host, your theme and your plugins, as Kiran's did.

Pick a platform to see its numbers:

Playground: platforms in the field
WordPress: sites on phones
  1. Sites with Core Web Vitals data2,513,839
  2. Pass all three Core Web Vitals49.0%
  3. Good LCP56.3%
  4. Good INP90.0%
  5. Good CLS87.6%
  6. Good TTFB23.6%
Try it yourself
WordPress: sites on phones

Pick a platform. You see how many of its sites HTTP Archive found, and the share of them whose real visitors had good Core Web Vitals and a good TTFB.

From HTTP Archive's Technology Report, its latest month. A site counts as good for a metric when at least 75% of its visits were good. Passing all three means good LCP and CLS, and good INP where there is INP data.

What you can and can't change

Ravi has been watching. Should he move his own shop to Shopify? First he wants to know what he would still control.

Real-life analogyA market stall or your own shop

At a covered market, the market runs the roof, the lights and the doors. You set out your stall: what you sell, and how it looks. In your own shop, you choose everything, down to the heating. But when the boiler breaks, you fix it.

In real life: The market's roof, lights and doors
In JavaScript: Shopify's servers, cache and CDN
In real life: Your stall: your goods and your display
In JavaScript: Your theme and your apps
In real life: Your own shop
In JavaScript: WordPress on a host you choose
In real life: Fixing your own boiler
In JavaScript: Setting up your own cache and CDN

Read each row across: one part of a site, and who controls it on each platform.

Who controls what
WhatWordPress on your own hostShopify
The server and the page cacheYours to choose: the host, a caching plugin, or both.Shopify's. Its servers and its cache come with every store.
The CDNYours to add, for files and even whole pages.Shopify's own CDN, backed by Cloudflare, for every store.
The theme's codeEvery file: PHP, CSS and JavaScript.Every file: Liquid, CSS and JavaScript.
Plugins or appsYours to add, remove, or limit to some pages.Yours to install and remove. App blocks go wherever you place them.
The platform's own scriptsWordPress's own files. You can dequeue most of them.content_for_header is Shopify's. Its docs say not to change it, and you can't defer it.
The checkoutYours: WooCommerce's pages, on your server.Shopify's. Deeper changes need extensions, and some need Shopify Plus.

On Shopify, the theme is all yours. It's written in Liquid, Shopify's template language. Here is the top of a Shopify theme, and a product photo:

A Shopify theme's head and photoLiquid
<head>  {{ 'theme.css' | asset_url | stylesheet_tag }}  {{ content_for_header }}</head> {{ product | image_url: width: 800 | image_tag: sizes: '(max-width: 600px) 100vw, 600px' }}
  • Line 2 is the theme's own CSS. asset_url serves it from Shopify's CDN.
  • Line 3 is content_for_header. Shopify's docs say it "Dynamically returns all scripts required by Shopify", and that you "shouldn't try to modify or parse" it. You can't defer it either. Shopify sends the head in two parts, and everything above this tag comes first. So its docs say to put the CSS the first paint needs above it, as line 2 does.
  • Line 6 asks for the photo 800 px wide with image_url. Then image_tag writes the img tag, with srcset, width and height. Shopify picks WebP or AVIF for browsers that support them.

Shopify measures for you too. Its web performance reports show LCP, INP and CLS, "based on real user data from the past 30 days", at the 75th percentile. On WordPress, you read CrUX, or collect your own.

Working on any platform

  • Start with real visits: CrUX, or the platform's own reports.
  • Find who added each file: the theme, a plugin, an app, or the platform.
  • Remove what you don't use. Limit the rest to the pages that need it.
  • Load app scripts with async or defer, or as app blocks.
  • Turn on the platform's cache and CDN. Keep carts and checkouts out of the cache.
  • Report what you can't change to whoever made it.

Ravi's answer: Shopify would run the parts Kiran had to set up herself. But the apps and the theme would still be his to check, file by file.

Where does each fix live?

Sort each problem by who can fix it:

Who can fix it?
  • Contact Form 7's files on a product page with no form
  • A wishlist plugin that almost nobody uses
  • A gallery zoom that downloads the full-size photo on every visit
  • A Shopify app's script tag that blocks the first paint
  • A plugin you need, whose own script is large
  • The scripts Shopify puts in content_for_header
  • Which CDN serves a Shopify store's files
Try it yourself
0 of 7 correct

Sort each problem by who can fix it.

Choose a category for every card. You can change an answer at any time; Reset clears them all.

Common mix-ups

  • "WordPress is slow." No. The same WordPress painted Kiran's photo at 3,692 ms before her fixes, and at 1,292 ms after. The plugins and the cache made the difference.
  • "A plugin only loads where you use it." No. Contact Form 7 loads its files on every page unless you tell it not to. The wishlist brought React to a page with one heart on it.
  • "A page cache makes everything fast." No. It answers pages that are the same for everyone. The answer to Add to cart was built by PHP every time.
  • "async means the script runs later." No. It means the browser keeps reading while the script downloads. The script runs as soon as it arrives.
  • "Uninstalling an app removes all of its code." No. Shopify removes an app's blocks. Code an app pasted into theme files can stay behind.
  • "A hosted platform makes every store fast." No. Most Shopify sites pass, but not all: the apps and the theme still decide a lot.

Practice exercises

Answer each one first, then open the hints if you need them.

Exercise 1 · Warm-upDrupal's good LCP

This uses the Technology Report's numbers for Drupal, another platform, on desktops. What does it print?

Starter codePop out in the code editor (opens in a new tab)JavaScript
// Drupal sites on desktops: [good LCP, measured].
const lcp = [72292, 82712];

console.log(`${((lcp[0] / lcp[1]) * 100).toFixed(1)}%`);

Answer, then press Check. Spacing and letter case don’t matter.

    Exercise 2 · Warm-upA deferred script with a blocking neighbour

    This models, in a few lines, a rule WordPress follows when it prints a deferred script. What does it print?

    Starter codePop out in the code editor (opens in a new tab)JavaScript
    // A model of WordPress's rule, written for this lesson.
    const scripts = {
      slider: { wants: "defer", neededBy: ["gallery"] },
      gallery: { wants: "blocking", neededBy: [] },
    };
    
    function printed(name) {
      const script = scripts[name];
      const blockingDependent = script.neededBy.some((other) => scripts[other].wants === "blocking");
      return blockingDependent ? "blocking" : script.wants;
    }
    
    console.log(printed("slider"));

    Answer, then press Check. Spacing and letter case don’t matter.

      Exercise 3 · PracticeWhen the stars came

      On the async version, when were the review app's stars on the page, in ms after Asha asked for it?

      Answer, then press Check. Spacing and letter case don’t matter.

        Exercise 4 · PracticeThe wishlist's stylesheets

        How many kB of CSS, compressed, did the wishlist plugin's files add to the page?

        Answer, then press Check. Spacing and letter case don’t matter.

          Exercise 5 · ChallengeThe biggest script

          Open the course's trace of Kiran's page before the fixes in Chrome's DevTools. Which JavaScript file was the biggest download?

          Answer, then press Check. Spacing and letter case don’t matter.

            Exercise 6 · ChallengeA size for app scripts

            Shopify suggests a size for the JavaScript an app block or app embed block loads. How big, compressed?

            Answer, then press Check. Spacing and letter case don’t matter.

              Check your understanding

              For each question, ask two things: who added this, and who can change it?

              The CMS and e-commerce platforms quiz · 7 questionsScore: first tries count
              1. Question 1 of 7Why did Contact Form 7's files load on the Mint tea page, which has no form?

                Choose an answer to see the explanation.

              2. Question 2 of 7A script tag is pasted at the top of the head, with no async and no defer. What does the browser do when it reaches it?

                Choose an answer to see the explanation.

              3. Question 3 of 7In the course's recording, what did the page cache not speed up?

                Choose an answer to see the explanation.

              4. Question 4 of 7What does line 9 of the cache-rule example print?

                Read the code, then predictPop out in the code editor (opens in a new tab)JavaScript
                // May the page cache answer this request?
                function fromCache(request) {
                  if (request.method !== "GET") return false;
                  return !request.cookies.includes("woocommerce_items_in_cart");
                }
                
                console.log(fromCache({ method: "GET", cookies: "" }));
                console.log(fromCache({ method: "POST", cookies: "" }));
                console.log(fromCache({ method: "GET", cookies: "woocommerce_items_in_cart=1" }));

                Choose an answer to see the explanation.

              5. Question 5 of 7In HTTP Archive's Technology Report, when does a platform's site count as passing the Core Web Vitals?

                Choose an answer to see the explanation.

              6. Question 6 of 7On Shopify, which of these does Shopify manage, not the store owner?

                Choose an answer to see the explanation.

              7. Question 7 of 7A Shopify app moves from the ScriptTag API to an app embed block. What changes for the store?

                Choose an answer to see the explanation.

              Key takeaways

              • On a platform, most of the page is other people's code. Find who asked for each file before you change anything.
              • A plugin can load its files on every page. Remove what you don't use, and limit the rest to the pages that need it.
              • A script pasted at the top of the head blocks the first paint. Load app scripts with async or defer, or as app blocks.
              • A page cache skips PHP for pages that are the same for everyone. Carts and checkouts are still built every time.
              • Shopify runs the server, the cache and the CDN for you. On WordPress, you choose them yourself.
              • Field data per platform is an average. Your own site's numbers come from your own choices.

              Remember the one-liner.
              On a platform, you rarely write the code: you choose what runs on the page, and who answers it.

              Looking back at Stage 11

              This lesson ends the stage on architecture and frameworks. Each lesson asked where the work happens, and when:

              • Rendering strategies: client, server, static, and islands, by their metrics.
              • Streaming: send the page in pieces, so slow data doesn't hold back the rest.
              • Hydration: how much JavaScript wakes the page up, and when.
              • The edge: running near the visitor helps only when the data is near too.
              • Frameworks: React, Next.js, Angular, Vue, Svelte, Astro and Qwik, each with its own tools.
              • Platforms: when you didn't write the code, choose what runs and who answers.

              Sources

              The facts on this page come from these docs, source files and datasets:

              Coming next: Testing on low-end devices, the first lesson of Stage 12. Real phones, remote debugging and thermal throttling: see your site the way most people do.

              CompleteFrontend Clear concepts. Working examples.