Fix Cloudflare 'StorageType.persistent is deprecated' Error in Google Lighthouse
Overview
When running Google Lighthouse audits on your website, you may encounter a Best Practices warning that significantly impacts your score:
Error Message:
'StorageType.persistent' is deprecated. Please use standardized 'navigator.storage' instead
This error originates from Cloudflare's Bot Management JavaScript and can reduce your Lighthouse Best Practices score. The issue stems from Cloudflare using outdated Web API methods in their bot detection scripts.
Why This Happens
Cloudflare's Bot Management feature injects JavaScript code that uses the deprecated StorageType.persistent
API instead of the modern navigator.storage.persist()
method. This has been a persistent issue for several years, with Cloudflare being slow to update their implementation.
Community Discussion:
Impact on Your Website
- Lower Lighthouse scores - Affects Best Practices rating
- Console warnings - Clutters browser developer console
- Future compatibility - May break when browsers remove deprecated APIs
- SEO implications - Google considers Core Web Vitals and Lighthouse scores for ranking
Solution: Disable JavaScript Detections
Step 1: Access Cloudflare Dashboard
- Log in to your Cloudflare dashboard
- Select the domain experiencing the issue
- Navigate to Security → Settings → Bot traffic
You should see the Bot Management configuration panel:
Step 2: Disable JavaScript Detections
In the Bot Management settings:
- Locate the JavaScript Detections option in the right-hand column as shown below
- Toggle the switch to OFF (disabled)
- The change will be applied automatically
Important: This setting may take a few minutes to propagate across Cloudflare's global network.
Step 3: Verify the Fix
After disabling JavaScript Detections:
- Run a new Lighthouse audit
- Check that the StorageType.persistent error is resolved
Conclusion
Disabling Cloudflare's JavaScript Detections is an effective solution for the StorageType.persistent
deprecation warning. However, keep in mind the following benefits/considerations:
✅ Benefits:
- Eliminates Lighthouse Best Practices warnings
- Improves page performance slightly
- Removes deprecated API console errors
- Better Core Web Vitals scores
⚠️ Considerations:
- Slightly reduced bot protection
- Possible need for alternative security measures
- Ongoing monitoring requirements
- Potential impact on high-risk sites
Recommendation: This solution works best for content sites, blogs, and marketing pages where the SEO benefits outweigh the minimal security trade-offs. For e-commerce or high-security applications, consider alternative solutions or additional security measures.