Home Documentation Blog JavaScript The wpsafelink.js One-Tag Embed

The wpsafelink.js One-Tag Embed

The Blog JavaScript is the fastest way to monetize a website with WP Safelink. You drop a single <script> tag before the closing </body> tag, and from that moment every outbound download link on the page is rewritten into an encrypted safelink that routes visitors through your monetized countdown page. It works on any website — a WordPress blog, a static HTML site, Blogger, or a custom CMS — because the rewriting happens client-side in the visitor’s browser, with no plugin needed on the other site.

What the one-tag embed does

WP Safelink generates a personalized JavaScript file at https://YOUR-SITE/wpsafelink.js. When a page loads that file, the script scans every <a> link on the page and, for each link that matches your conversion rules, replaces the href with a safelink that points back to your WP Safelink install. Visitors who click pass through your countdown page and AdSense ad units before reaching the real download URL — turning ordinary download links into ad revenue automatically.

  • One tag, whole site. Paste it once into your footer template and every page is covered.
  • No manual link conversion. You keep writing posts with normal <a href="https://...">Download</a> links.
  • Works off-WordPress. The tag runs in the browser, so it can monetize a static site, Blogger, Ghost, or any platform that lets you edit HTML.
  • Same encryption as the plugin. Links are encrypted with AES-256-ECB using the shared WP Safelink delimiter, so your server decrypts and redirects them exactly like manually created safelinks.

How it works, step by step

  1. A visitor opens a page on your blog that loads wpsafelink.js.
  2. The script waits until its bundled encryption library (CryptoJS) is ready, then walks every link on the page.
  3. Each link is checked against your include / exclude rules to decide whether it should be converted.
  4. Matching links get a fresh random key, are encrypted, and the href is rewritten to your safelink base URL (the converted link also opens in a new tab).
  5. When the visitor clicks, they land on your WP Safelink countdown page, see your ads, and are redirected to the original download after the timer finishes.

What it looks like

A blog page with download links being rewritten into WP Safelink safelinks by the wpsafelink.js tag
The wpsafelink.js tag rewrites outbound download links into monetized safelinks right in the visitor’s browser.

The Blog JavaScript is one of three monetization methods WP Safelink offers. Pick whichever fits your workflow — they all produce the same kind of encrypted safelink:

MethodBest forHow links get converted
Blog JavaScript (this tag)Any site, especially non-WordPress blogsAutomatically, in the browser, for matching links on every page
Shortcode & PHPHand-picking specific links inside WordPressOne link at a time via [wpsafelink=URL]
Auto Convert (server-side)A separate WordPress content blog paired to your safelink siteAutomatically on the server — see the Auto Convert Link docs

If you run a separate WordPress content blog and prefer server-side conversion instead of a browser script, see the installation guide and the Auto Convert Link extension.

💡 Note: The Blog JavaScript and the manual shortcode are built into your WP Safelink install. Advanced multi-site automation — like server-side auto-conversion on a second WordPress blog — is handled by the PRO Auto Convert Link extension, which is gated behind a valid WP Safelink PRO license.

Was this article helpful?

Need More Help?

Can't find what you're looking for? Contact our support team.

Contact Support