You need a JavaScript snippet on every page. Not a plugin.
A vendor gave you a 10-line JavaScript widget. An analytics team wants you to add a custom dataLayer push. A marketer wants a chat widget. Each one is just a <script> tag, but each time you install an entire plugin just to paste the code in.
The alternative, wp_head action hooks in functions.php, ties the script to the active theme. Switch themes next year and the script disappears.
What most people do instead
A better way: named, toggleable JS snippets
Run create custom script. Name it ("chat widget", "pixel tracker"). Paste the JS. Each snippet outputs as an independent <script> block on every page load. Toggle any snippet off from the Startup Commands page. No theme dependency, no redeploy.
Shown in advanced mode, where commands start with tp. In easy mode you type the same command without the tp prefix.
The code is output raw inside <script> tags. You're responsible for its correctness. Bad JavaScript can break your frontend. Test locally before registering a snippet site-wide, same caveat as any header-footer plugin.
How it works
Auto-registers as a startup command. On every page load, outputs an independent <script> block. Each registered snippet is separate, delete it from Startup Commands to remove its output. Each snippet has a name, so a dozen of them stay organized.
-code parameter.<script> block. Accumulates, multiple entries = multiple blocks.| Parameter | Value |
|---|---|
-name | Display name (e.g., "intercom chat", "ga4 dataLayer") |
-code | Raw JavaScript. Output verbatim inside <script> tags. |
| Model | Accumulate, each run adds one independent script block |
| Scope | Frontend pages only (admin JS unaffected) |
| Can be used in |
Real example
You want Intercom chat on your site. Intercom gives you a 10-line JavaScript snippet. Without this command, you'd paste it into a plugin like Insert Headers and Footers and hope you don't need to change it later.
With this command: run tp create custom script -name="intercom chat" with the snippet. It's now live on every page. Six months later, your marketing team wants to gate Intercom to logged-in users only. Open Startup Commands, find the "intercom chat" entry, add a condition "user is logged in". Chat only loads for logged-in users, no code changes.
Goes further with TrueCommander
{{var.intercom_app_id}}. Rotate without editing code.Frequently asked questions
tp create custom script -code="console.log('hi');" and the snippet is injected into the frontend. No theme files change, so a theme update will not remove it.-location, for example -location=footer, to control where the snippet is output, which matters for scripts that must run before or after the page content loads.<script> block, so you can keep separate snippets for separate jobs. Give each a -name to tell them apart, and remove one without affecting the others.