On this page
What this issue is
document.write() is an old JavaScript method that writes HTML straight into the page while it loads. Synchronous XHR is a network request (XMLHttpRequest with the async flag set to false) that freezes the page until the server answers. Browsers mark both as deprecated or harmful and print warnings in the console.
- Sync XHR blocks the page, so buttons and forms feel frozen while the request runs.
- document.write can inject a script that blocks rendering, so the page appears later, especially on slow mobile connections.
- Chrome can skip cross-site scripts injected with document.write on slow connections, so a tag or widget may silently not load for some visitors.
- Calling document.write after the page has loaded can wipe the whole page, which breaks the funnel step.
- Browsers may remove these APIs in the future, turning a warning into a real failure.
- Page starts loadingVisitor on a slow mobile connection
- document.write adds a scriptBrowser decides to skip it
- Widget or tag missingChat, form helper or tracking not loaded
- Lead or event lostNo conversion recorded
A cross-site script written with document.write may be skipped on a slow connection, so later steps depend on something that never loaded.
Open DevTools
Open your landing page, form page and checkout in Chrome. Press F12 (or Cmd+Option+I on Mac) and open the Console tab.
Reload with the console open
Tick 'Preserve log', reload, and make sure the 'Verbose' level is enabled so violations show.
Filter for the warning
Type document.write or Synchronous XMLHttpRequest in the filter box.
Click the source link
The right-hand file name shows which script triggered it. Expand the stack trace to see the caller.
Test a slow connection
In the Network tab, set throttling to Slow 4G and reload. Look for the message that a script was not loaded via document.write.
Try Lighthouse
Run Lighthouse from DevTools. The best-practices section lists 'Avoids document.write()' when it finds a problem.
Identify the plugin or theme
Use the DevTools source link. File paths containing /wp-content/plugins/name/ or /wp-content/themes/name/ tell you the owner.
Update or replace it
Update the plugin or theme first. If the warning stays, check the vendor changelog or switch to an alternative. Test on a staging copy.
Find the source
Paths with /cdn/shop/t/ are theme files. Third-party app scripts come from the app's own domain.
Update theme or remove the app snippet
Update the theme, or in Online Store > Themes > Edit code search for document.write. For apps, contact the developer or remove the app's leftover code.
Check Custom HTML tags
Open each Custom HTML tag and look for document.write. Old vendor snippets often use it.
Replace with a template or async loader
Use the vendor's current tag template from the Community Template Gallery, or load the script by creating a script element (see the code below). Also untick 'Support document.write' unless a tag really needs it.
Search custom code
Check Site settings > Custom code and each page's custom code, plus embed elements, for document.write.
Swap in the async version
Replace it with the vendor's current snippet, or the script element approach below.
Check tracking and custom code areas
Look in funnel or website Settings > Tracking Code and Custom Code blocks for old snippets that use document.write.
Replace the snippet
Paste the vendor's current async snippet, then reload the page and check the console.
Review custom code
Open Settings > Custom code (or Advanced > Custom Code, depending on your dashboard) and review each snippet.
Update the snippet
Replace old snippets with current ones from the vendor. Wix's own scripts are not editable, so report those to Wix support.
Review code injection
Open Settings > Advanced > Code Injection and check header, footer and any Code Blocks.
Replace old snippets
Use the vendor's current snippet. Code Injection is not available on every plan.
Replace document.write with DOM methods
Create the element and append it, or add the script tag directly in HTML with async or defer.
Replace sync XHR with fetch
Use fetch or async XHR and handle the result in a callback or with await.
var s = document.createElement('script');
s.src = 'https://example.com/widget.js';
s.async = true;
document.head.appendChild(s);// Before (blocks the page)
// var xhr = new XMLHttpRequest();
// xhr.open('GET', '/api/data', false);
// xhr.send();
// After
fetch('/api/data')
.then(function (res) { return res.json(); })
.then(function (data) {
console.log(data);
})
.catch(function (err) {
console.error('Request failed', err);
});Deprecated
- document.write injects a blocking script
- Sync XHR freezes the page
- Console shows violation warnings
- Script may be skipped on slow connections
Modern
- Script added with async or defer
- fetch runs without blocking
- Console is clean
- Script loads reliably
- Reload each funnel page with the Console open: no document.write or Synchronous XMLHttpRequest messages remain.
- Re-run Lighthouse and check that 'Avoids document.write()' passes.
- Throttle to Slow 4G and confirm the widget or tag still loads.
- Submit a test lead and check it reaches your inbox or CRM.
- Check in GA4 DebugView or your ad platform's tag tool that conversion events still fire.
- Load third-party scripts with async or defer.
- Keep themes, plugins and apps updated.
- Check the console on a staging page before publishing any new tag.
- Ask vendors for their current snippet rather than copying one from an old guide.
- Review Custom HTML tags in your tag manager a few times a year.
- Add a console check to your release checklist.
Example: illustrative scores only, not measured data. Risk depends on which script uses the API.
Questions people ask
Why does Chrome say 'Avoid using document.write()'?
Chrome shows this violation when a script calls document.write, which can block page rendering. It usually comes from an old theme, plugin or third-party snippet. Find the file in the console's source link and update or replace it.
Is document.write bad for SEO?
It is not a direct ranking penalty, but it can slow rendering and Lighthouse flags it in best practices. If it makes a script fail to load, content or tags may be missing. Replacing it with async loading is the safer choice.
How do I fix 'Synchronous XMLHttpRequest on the main thread is deprecated'?
Change the request to be asynchronous, ideally with fetch, and handle the response in a callback or with await. If the call comes from a third-party script, update that script or contact the vendor.
Why is my script not loading because of document.write?
On slow connections Chrome can skip cross-site scripts that are injected with document.write. The script never runs, so the widget or tag is missing. Load it with a script element or an async script tag instead.
Can Google Tag Manager cause document.write warnings?
Yes, a Custom HTML tag with an old vendor snippet can use document.write. Replace it with the vendor's current template or load the script by creating a script element. Only enable 'Support document.write' if a tag truly needs it.
Do deprecated API warnings stop my forms or tracking from working?
Usually not, because they are warnings. They become a problem when the browser skips the script or the page freezes. Always test a submission and your conversion events after any change.
Does FunnelGuard detect deprecated API warnings?
No, not yet. It is a possible future check. FunnelGuard does catch real funnel failures such as broken steps, missing tracking hits and test leads that do not arrive.
Related issues
- PRF-116Uncaught JavaScript exception on page loadFix guide
- PRF-117Console error on a funnel stepFix guide
- PRF-125Content Security Policy blocks a needed script or tagFix guide
- PRF-126Mixed content blocked (http script on https page)Fix guide
- PRF-128JS error only on old browsers (optional chaining, etc.)Fix guide
- PRF-134Button does nothing on click (dead click)Fix guide