This guide shows how to add a npm downloads badge for WordPress in about a minute, with no plugin: you paste one snippet into the post or page itself, because it belongs beside the install command, in the post or docs page that teaches it. No plugin. WordPress accepts raw HTML in a Custom HTML block, which is all this needs.
What this npm downloads badge for WordPress shows
The npm downloads badge shows how many times a package was downloaded in the last day, week or month, using npm's public download counts. It's for JavaScript library authors who want that number on their docs or landing page, not only on npmjs.com. Scoped packages are supported.
How to add a npm downloads badge to WordPress
- Step 1
- Edit the post or page where you want it to appear.
- Step 2
- Click the + block inserter and search for Custom HTML.
- Step 3
- Paste the snippet into that block — not into a paragraph block.
- Step 4
- Preview, then Publish or Update.
- Block theme or a different editor?
- On the Classic Editor, switch from Visual to the Text tab before pasting. The Visual tab strips script tags without telling you.
Where it works best on a WordPress site
On WordPress, the right spot is the post or page itself. Put it next to the install command, in the docs page or post that teaches people to use the package. That's where a reader is deciding whether to run npm install.
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
Download counts include automated installs from CI systems and mirrors, so they overstate the number of people using a package. Use them as a relative signal, not a user count.
WordPress questions
- Do I need a plugin to add a npm downloads 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?
- The post or page itself, because it belongs beside the install command, in the post or docs page that teaches it.
- 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.
- Do npm download counts equal users?
- No. They include automated installs from build servers and mirrors, so treat them as a rough popularity signal rather than a count of people.