On this page
What this issue is
Many sites load JavaScript from other domains: a CDN, an old plugin vendor, a widget, a tracking helper. Your page trusts that domain completely. Whatever file it returns runs with the same power as your own code.
The risk appears when the company behind that domain stops paying for it, shuts down, or sells it, or when its account is compromised. Someone else can then register or control the domain and serve different JavaScript from the same URL. Your page still points at it, so every visitor gets the new code. This is a form of supply chain attack: the attacker never touches your server.
Why it costs you leads or sales
Injected code can send visitors away from your form or checkout, replace your buttons, or capture what people type. Lost trust follows: browsers and security tools may warn visitors or block your site, and ad platforms can disapprove ads that land on pages with malicious behaviour. Search engines may also flag the site.
- Visitor opens your pageYour HTML loads normally
- Old script URL requestedPoints to an expired domain
- Attacker code runsRedirect, skimmer or pop-up
- Form or checkoutVisitor never converts, or data is stolen
The break happens outside your server, which is why it goes unnoticed.
Example: illustrative numbers for a site whose landing page starts redirecting some visitors.
How to check if your site has it
You need a list of every domain your pages load code from, then a check on who controls each one.
List external hosts
Open your key pages in Chrome, press F12, go to the Network tab, filter by JS and reload. Note every domain that is not your own. Check pages with forms and checkout too.
Search your source
View page source and search for
<script src="http,//andimport(. Also check theme files, plugin settings and tag manager tags that inject scripts.Look up each domain
Use a WHOIS or RDAP lookup (for example lookup.icann.org). Note the expiry date and whether the registration date is recent. A domain registered recently that used to be a vendor's is a red flag.
Test each URL
Open the script URL in a browser. A 404, a parked page, a changed file or unexpected code means you should remove it. Ask whether you still use the vendor at all.
Check for unexpected behaviour
Test your pages on a phone, from an ad click and in a private window. Watch for redirects and pop-ups.
How to fix it
If you suspect a script is already serving bad code, remove it first, then investigate. How you remove it depends on where it was added.
Find the source
Search the theme and plugin files for the domain, and check Appearance > Theme File Editor, header and footer injection plugins and page builder custom code.
Remove or replace
Deactivate and delete abandoned plugins that load it. Replace with a maintained alternative, or host the file yourself if the licence allows.
Check theme code
In Online Store > Themes > Edit code, search for the domain in theme.liquid and snippets.
Check apps
Uninstall unused apps, and look in Settings > Customer events for custom pixels that load external scripts.
Review Custom HTML tags
Open the container, filter tags by type Custom HTML and search for the domain.
Pause and publish
Pause or delete the tag, preview it in Tag Assistant, then publish a new version.
Check custom code
Look in Site settings > Custom code, and in page settings and embed elements for the domain.
Remove and publish
Delete the script and publish the site.
Check tracking code
Review the custom code areas in Sites > Funnels or Websites (per-page and funnel-level header and footer code) and custom code elements.
Remove and republish
Delete the script and save and publish the page.
Check custom code
Open Settings > Custom code (under Advanced) and look for the domain, plus any embed elements.
Delete the snippet
Remove it and publish.
Check code injection
Go to Settings > Developer Tools > Code Injection and check header, footer and any code blocks.
Remove and save
Delete the script line and save.
Search the repository
Run a search across templates and build files for the domain, for example with grep.
Remove or self-host
Delete the tag, or download a reviewed copy of the file and serve it from your own domain or a CDN you control.
grep -rn "old-cdn-host.example" ./src ./templates ./publicThen lock down the scripts you keep. Subresource Integrity (SRI) makes the browser refuse a file if its content differs from a hash you recorded. It works for static, versioned files, not for scripts that change by design.
<script src="https://cdn.example.com/lib/1.2.3/lib.min.js"
integrity="sha384-REPLACE_WITH_REAL_HASH"
crossorigin="anonymous"></script>curl -s https://cdn.example.com/lib/1.2.3/lib.min.js | openssl dgst -sha384 -binary | openssl base64 -AA Content Security Policy (CSP) limits which domains may run scripts. Start in report-only mode so you do not break the site.
Content-Security-Policy-Report-Only: script-src 'self' https://www.googletagmanager.com https://cdn.example.com; report-uri /csp-reportsHow to confirm it's fixed
- The Network tab shows no request to the removed domain on key pages
- Every remaining external script host is one you recognise and the vendor is active
- Pinned scripts load with no integrity errors in the Console
- Forms submit and checkout reaches the payment step normally
- No redirects or pop-ups on mobile, in a private window or from an ad click
- CSP report-only logs show no unexpected hosts
How to prevent it happening again
- Keep a written inventory of every third-party script, its owner and why it is there
- Remove scripts when you cancel a vendor, plugin or campaign
- Self-host or pin versioned files with SRI where possible
- Deploy a CSP with a short allow-list
- Load third-party code through one reviewed tag manager container with limited publish access
- Review domain expiry and ownership of hosts you depend on every quarter
Example: Month 0
A vendor shuts down. Your site still loads its script.
Example: Month 6
The vendor's domain registration lapses.
Example: Month 7
A stranger registers the domain and serves new code at the old URL.
Example: Month 7
Your visitors start getting redirected or skimmed.
After audit
You remove the tag and add SRI and CSP.
How FunnelGuard handles this
FunnelGuard does not check for this yet. It is a possible future check. Today it does not scan your pages for expired or hijacked script domains, and it cannot tell you whether a script's content has changed.
What FunnelGuard does cover nearby: a robot visitor runs your real journeys (lead forms, checkouts, booking and chat buttons) on a schedule, checks each step and the tracking hits sent to platforms such as GA4, Google Ads and Meta, and checks that test leads reach your inbox and CRM. If injected code redirects the journey or breaks a form step, a failed check can show up as a broken journey, with a screenshot, but the alert would not name the hijacked script as the cause.
To watch for this issue yourself, run the audit above every quarter, set expiry reminders for vendor domains you rely on, use the CSP report-only endpoint to see unexpected hosts, and check Google Search Console's Security issues report. You can also start with the free read-only website audit or the Free plan (1 site, 2 journeys, daily checks, no card) to monitor that your key journeys still work.
Questions people ask
Can an expired domain really serve malicious JavaScript on my site?
Yes. If your page loads a script from a domain whose registration lapsed, anyone who registers it can serve code at that same URL. Your visitors' browsers run it with the same access as your own scripts.
How do I find third-party scripts on my website?
Open the page in Chrome, press F12, go to the Network tab, filter by JS and reload. Every domain that is not yours is a third-party host. Also search your theme, plugin settings and tag manager for script tags.
How do I check whether a script domain has expired or changed owner?
Look the domain up with a WHOIS or RDAP tool such as lookup.icann.org and check the registration and expiry dates. A recent registration date on a domain an old vendor used is a warning sign. Also open the script URL to see if it returns different content.
What is Subresource Integrity and does it stop a hijacked script?
Subresource Integrity adds an integrity hash to a script tag, and the browser refuses to run the file if its content does not match. It protects static, versioned files. It does not suit scripts that the vendor changes on purpose.
What is a Content Security Policy and how does it help?
A Content Security Policy is a header that lists the domains allowed to run scripts on your page. A script from any other host is blocked. Start with Content-Security-Policy-Report-Only to see what would break before you enforce it.
What should I do if my site already loaded a malicious script?
Remove the script, rotate passwords and keys used on affected pages, and scan for other changes. If checkout was affected, tell your payment provider. Check Search Console for security warnings.
Does FunnelGuard detect hijacked third-party scripts?
No, not yet. It is a possible future check. FunnelGuard does run your real journeys on a schedule, so a form or checkout that breaks gets a screenshot, but it does not identify hijacked script domains.
Related issues
- PRF-115Abandoned plugin script from a dead CDN hostFix guide
- PRF-099Third-party script fails to load (chat, form, payment widget)Fix guide
- PRF-111Third-party script throws console errorsFix guide
- PRF-112Tag manager container fails to load (blocked, 404)Fix guide
- PRF-113Ad blockers break core functionality (site depends on blocked script)Fix guide
- PRF-100Third-party script slow and blocks renderingFix guide