Is using document.write to improve store speed a genuine fix or a fake?

Topic summary

A Shopify store owner discovered their hired “expert” used fraudulent code to artificially inflate PageSpeed scores without genuine performance improvements. The scam involves document.write with conditional logic that detects PageSpeed Insights/Lighthouse testing tools and serves them an empty page, resulting in falsely high scores (90-100) while actual users see the unchanged slow site.

Key Technical Details:

  • Code checks user agent for ‘Chrome-Lighthouse’ and similar testing identifiers
  • Returns minimal HTML to testing tools, full site to real visitors
  • Located in theme.liquid file, often wrapped in {%capture pDescription%} tags
  • Uses obfuscated hex strings to hide detection logic

Community Impact:

  • Multiple users report identical scams from Fiverr and Shopify Experts marketplace
  • “Web Nation Media” specifically named as perpetrator
  • Negative SEO consequences: Google may not properly index/rank affected stores
  • Some note “Shoptimized theme” uses similar tactics

Resolution:
Victims successfully removed malicious scripts by deleting the conditional code blocks and capture tags from theme.liquid. Discussion remains ongoing regarding legitimate speed optimization alternatives.

Summarized with AI on November 24. AI used: claude-sonnet-4-5-20250929.

Just found similar script,

I’ve deleted it with the 3 elements together:

{%capture pDescription%} and {% capture vendors %} and their corresponding closing tags - {%endcapture%}.

-thank you guys from the chat: https://community.shopify.com/c/site-speed/store-speed-scam-shopify-speed-do-not-match-lighthouse-speed/td-p/1302210/page/2