Skip to content
Nazmul Nikhil
Menu

Ensure CSP Is Effective Against XSS Attacks (PageSpeed Insights)

PageSpeed checks your Content Security Policy. It's informational and doesn't lower the score. Here's what it means and a safe way to start a CSP.

Nazmul Nikhil

By

Head of SEO & Assistant Manager, Digital Marketing at Notionhive

Published 1 min read
Ensure CSP Is Effective Against XSS Attacks (PageSpeed Insights)
Photo: Filip Szalbot on Unsplash

In short

A Content Security Policy (CSP) is an HTTP header that tells the browser which scripts may run, limiting the damage from cross-site scripting (XSS). PageSpeed checks whether you have one and whether it's strict (nonce- or hash-based). It doesn't affect the Best Practices score. Adding a strict CSP is a real security win, but it can break sites if done carelessly, so start in report-only mode.

This appears under Trust and Safety on most sites, even ones scoring 100, because it's informational.

A cautious path

  1. Add Content-Security-Policy-Report-Only with a basic policy.

  2. Watch the browser console and reports for what would be blocked.

  3. Adjust, then switch to the enforcing header.

Content-Security-Policy-Report-Only: script-src 'self' https://www.googletagmanager.com; object-src 'none'; base-uri 'self'

Sites with many third-party tags or inline scripts (common with page builders) need more work; a developer should own this.

This guide isn't affiliated with or endorsed by Google.

Sources and references

TAGSPageSpeed InsightsEnsure csp is effective against xss attacksContent security policyCsp header
Nazmul Nikhil

About the author

Nazmul Nikhil

Head of SEO & Assistant Manager, Digital Marketing at Notionhive

SEO and AI search consultant in Dhaka, Bangladesh, helping small and mid-size businesses in the USA, UK, Australia and Canada.

Need help with this?

Get it fixed with Technical SEO

I find the issues that cost you traffic and fix them, starting with the pages that matter most.

Keep reading

Related articles

All Page Speed & Core Web Vitals posts →

Get the next guide in your inbox

One email when a new SEO or AI search guide goes live.

Ready to grow?

Get a free audit of your website, or book a 30-minute call to talk through your goals.

Nazmul Hasan

Talk to Nazmul directly

Reply within 24h

WhatsApp +880 1682835118
nazmulnikhil@gmail.com