Skip to main content

Shipping interactive tools inside a WordPress page builder

Single-file embeds, a theme that fights back and a cache that waits for a click.

Updated 4 min readMarkdown

Most advice about building small web tools assumes you control the page. We don't. At Carra Globe our free tools live inside WordPress pages built with Elementor, next to a theme, an SEO plugin and a cache plugin that all have opinions.

Over months of shipping and fixing them, a few rules settled in. None are clever. All of them came from something breaking.

One file, no head

Each tool is a single HTML embed pasted into an HTML widget. There is no <!DOCTYPE>, no <head>, no <title> and no meta tags in it. The SEO plugin already writes those for the page, and a second set would duplicate them or fight over which one wins.

That rule surprised more than one code reviewer. Validators flag a missing doctype straight away. The answer is that this is a fragment, not a document, and treating it as a document is how you end up with two canonical tags.

Scope everything to one wrapper

Our first calculator looked fine on a blank test page and fell apart on the live one. The theme's styles for select elements stretched our dropdowns across the whole row and broke the cost estimator layout.

The fix was boring and permanent. Every selector now sits under a single wrapper class or ID, and the few controls the theme likes to restyle get explicit widths. The HS Code Finder scopes its CSS under one ID for the same reason, and its background is transparent so it sits on whatever colour the page uses instead of looking like a pasted box.

Assume your JavaScript runs late

This was the bug that cost the most time. A performance setting in the cache plugin delays scripts until the visitor first interacts with the page. That is good for load scores and bad for any markup that expects a script to be ready.

We had added a static placeholder row so the volumetric calculator would not look empty before the script ran. Under delayed loading, typing digits into that row stopped working, because the handlers were not attached yet. We removed the placeholder and let the script build the whole interface. Anything interactive now comes from the script or not at all.

Wrap it, then export on purpose

Each tool runs inside an IIFE in strict mode. That keeps dozens of helper functions out of the global scope, where they could collide with the theme or another plugin.

The catch is inline handlers. A button with onclick="copyList()" needs copyList on window. Rather than leaking everything, we export only what the markup calls, deliberately and in one place. When a function is not in that list, it cannot be called from the page.

Let the builder do the builder's job

The quote buttons in the HS Code Finder do not open their own modal. They use the page builder's existing popup through its action link, so the form, its tracking and its styling stay in one place that can be edited without touching tool code.

The same thinking applies to our import and export glossary, which is also a custom embed with search and category filters. The tool handles search, and the page handles everything around it.

Test on the real page at phone width

Most of our layout bugs only appeared on the live page at mobile widths. Text that fitted on a desktop preview spilled out of its card on a phone.

We now check releases on the published page at phone width, and run the code through an HTML validator and a page speed test before calling it done. The validator still complains about the missing doctype. That one we ignore.

The short version

If you are building tools that will be pasted into someone else's CMS, write a fragment, scope it tightly, assume late JavaScript and test where it actually lives. It is less elegant than a standalone app and far more useful, because the tool sits right where people already are.

At Carra Globe those people are mostly importers and logistics teams working out codes, weights and documents before a shipment moves. When the shipment needs a named importer in a country where they have no entity, that is the work of our importer of record service.

About the author

  • Carra Globe is a global trade logistics company specializing in Importer of Record (IOR) and Exporter of Record (EOR) services across 175+ countries. We help businesses ship IT equipment and technology products internationally without needing a local entity — handling DDP shipping, freight forwarding, global trade compliance, warehouse & data center logistics, and white glove delivery under one roof.

No comments yet. Be the first to comment.