Urgent.News

What's breaking now, across thousands of outlets.

Tech

Making a calculator other sites can embed, on a fully static site

I run a small site for freelancers, Paid & Filed , and its most useful page is a free 1099 tax calculator that works out quarterly estimated tax. Bloggers, coworking spaces and accountants who write for freelancers kept wanting to put it on their own pages, so I made it embeddable. The site is a static Next.js export served from a Cloudflare Worker: no backend, no API keys, no per-site accounts.…

I operate a modest site for freelancers called Paid & Filed. One of its most valuable pages is a complimentary 1099 tax calculator that calculates quarterly estimated tax. Various bloggers, coworking spaces, and accountants who write for freelancers consistently requested embedding this calculator on their own web pages. Consequently, I created a feature enabling embedding.

The embed capability consists of a secondary route. The calculator is encapsulated within a single React component. The embed-friendly version is a distinct route, /embed/quarterly-tax-calculator/. This version excludes the site header, footer, and analytics tracking. The React component rendering the calculator is exported as a default function.

There are two key design choices involved. Firstly, the embed route is marked as noindex. This directive is enforced both in the page metadata and as an X-Robots-Tag header for /embed/* paths. This ensures that search engines direct users to the full calculator page instead of a condensed duplicate. The follow directive remains active for links contained within the embedded calculator, enabling them to contribute to SEO.

Second, analytics tracking and ad networks are disabled on embed routes via a layout check. This prevents the inclusion of third-party tracking code on the host page when a user embeds the calculator.

Embedding the calculator presents challenges since iframes do not dynamically adjust their height to accommodate their content. A fixed height either obscures the results or leaves an empty space, which becomes problematic as the calculator reveals additional sections. To address this, the embedded page reports its height to the parent page whenever it changes.

The EmbedHeight component measures the height of the main content area within the iframe, rather than the entire document body. This ensures that the parent page can expand but never contract based on the iframe's content.

The parent page includes a simple script to handle the height adjustment. This script listens for messages sent from the embedded calculator and updates the height of any matching iframes based on the received height value. The origin of the message is verified to ensure that only the genuine calculator can adjust the height, thereby preventing manipulation by other frames on the same page.

The script is optional; without it, the iframe retains its fixed height, albeit with potential scrolling issues. This script is essential as many content management systems strip script tags from published content, making it necessary for the fallback functionality to work.

Credit is given to the calculator provider through a plain link beneath the iframe. This credit link serves as a simple hyperlink in the host page, crediting the tool by name. It's worth noting that there is a temptation to format the credit text as bold or highlighted, but doing so could detract from the calculator's display and result in a less user-friendly experience. The primary focus should always be on providing a seamless and functional embedding experience for end-users.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Turning one TypeScript CardSpec into 49 static palette PNGs

Belle AI (aicoloranalysis.io) publishes downloadable color-palette cards: one for each of the twelve sub-seasons and four parent seasons, plus cards for 20 celebrity pages and 13 "color analysis for…

  • Belle AI generates 49 static palette PNGs from one CardSpec
  • CardSpec shape defines common structure for all cards
  • Route handler creates static parameters for all 49 cards

Implement Training File Export with Temporary Downloads (Presigned URLs, Retention)

The constraint that changes this design is large-file throughput. An education platform should keep export bytes off its application workers, issue a short-lived download URL only after authorization…

  • Implement export as immutable object with signed GET request URL.
  • Record timestamps and policy selection for reproducible audits.
  • Use storage service for large data path, API for control-plane job.

Exit codes in CI: what every number means and how to fix it

Exit codes in CI are the only thing a failed step gets to say about itself, which is why so much of debugging a pipeline comes down to reading one number.

  • Exit codes indicate success (0) or failure in CI pipelines
  • 0 means successful completion, others are convention-based
  • Bash reserves 127 (missing command) and 126 (executable issue)

More from Sunday 15 November →