This guide shows how to add a WordPress page speed badge in about a minute, with no plugin: you paste one snippet into your theme's header, before </head>, because one paste in the head gives every page its own score — the badge auto-detects which page it's on. No plugin. WordPress accepts raw HTML in a Custom HTML block, which is all this needs.
What this WordPress page speed badge shows
The page speed badge shows the page's mobile load speed and Lighthouse performance score, measured with Google's PageSpeed Insights API. It's a public, verifiable claim that your site is fast, which matters most to developers, agencies and anyone selling web work. The score is cached rather than re-tested on every visit, so the badge itself stays light.
How to add a page speed badge to WordPress
- Step 1
- In WP Admin go to Tools → Theme File Editor (on older or classic themes it's Appearance → Theme File Editor).
- Step 2
- Pick header.php from the file list on the right.
- Step 3
- Find the closing </head> tag and paste the snippet on the line directly above it.
- Step 4
- Click Update File, then purge your caching plugin.
- Block theme or a different editor?
- Block themes (Twenty Twenty-Four and friends) have no header.php. Use a header-scripts plugin such as WPCode, or your theme's Custom Code panel — anything that can inject into <head> sitewide works.
Where it works best on a WordPress site
On WordPress, the right spot is your theme's header, before </head>. Paste it once in the head and every page gets its own score, because the badge detects the page it's on. Show it where it supports a claim you're making, such as a footer on an agency site or next to a 'fast hosting' promise, and only once the score is one you're happy to show.
WordPress plan and editor requirements
WordPress.org sites you host yourself can use every method on this page. On WordPress.com, adding scripts with a Custom HTML block or a header plugin needs a plan that allows plugins and custom code (the Business plan or above at the time of writing), because lower WordPress.com plans strip script tags. If you're not sure which you have, check whether your dashboard has a Plugins menu.
Three things that trip people up on WordPress
- Purge your cache after pasting
- WP Rocket, W3 Total Cache, LiteSpeed Cache and your host's edge cache all serve a stored copy of your HTML. Until you purge, you'll be looking at the version from before you pasted and assuming the widget is broken. The widget's own data is fetched client-side on every load, so page caching never makes the numbers go stale — it only hides a freshly-added snippet.
- Exclude it from JS minify / combine
- Optimisation plugins that concatenate or defer every script can break an async third-party tag by moving it out of order. If the widget renders nothing after a purge, add the script URL to your plugin's JS exclusion list — in WP Rocket that's File Optimization → Excluded JavaScript Files. Nothing else needs changing.
- Use a Custom HTML block, never a paragraph
- WordPress sanitises script tags typed into a paragraph or the Visual editor tab, silently. The Custom HTML block, the Classic editor's Text tab, and Elementor's HTML widget all pass markup through untouched. If your snippet vanished on save, that's why.
Honest limits
It's a lab test from Google's servers, not a measurement of your real visitors, and the number moves a little between tests. A slow score is shown as it is, so fix the page before you put the badge on it.
WordPress questions
- Do I need a plugin to add a page speed badge to WordPress?
- No plugin. WordPress accepts raw HTML in a Custom HTML block, which is all this needs. Installing a plugin for this would mean another dependency and update cycle just to show one widget.
- Where exactly does the snippet go on WordPress?
- Your theme's header, before </head>, because one paste in the head gives every page its own score — the badge auto-detects which page it's on.
- Will it slow my WordPress site down?
- It adds one small script, loaded asynchronously, so it doesn't block your page from rendering. Any third-party script has some cost, so check your page speed before and after adding it. Your caching and optimisation plugins keep working exactly as before — the only thing to remember is to purge the cache after you paste, otherwise you'll be looking at the stored copy of your old HTML.
- Does it work with page builders like Elementor?
- Elementor: drag in the HTML widget and paste there. Divi: use a Code module. Beaver Builder: use the HTML module. WPBakery: use the Raw HTML element. Any builder with a raw-HTML or code block will render it.
- Where does the speed score come from?
- From Google's PageSpeed Insights API, using the mobile test. The result is cached, so the badge doesn't run a new test every time someone loads your page.