WEB-20Recommended
Load everything from your own site
Serve every file from your own origin, with no third-party origins. Send one HTML request, inline the critical CSS, host fonts and images yourself, and split scripts only by how long each part can be cached.
How to do it
Inline the CSS and host fonts and images yourself. Build scripts into one entry module. Split off a chunk only when it changes on a different schedule or loads on few pages, as Old HTTP/1 tricks on HTTP/2 explains. Set the CSP to 'self', plus a hash that allows the inline stylesheet. If a third-party script must stay, follow Load third-party scripts with integrity checks.
Examples
HTML example
<head>
<style>/* the whole stylesheet, inlined at build time */</style>
<script type="module" src="/assets/main-3f9a1c.js"></script>
</head>
HTTP example
Content-Security-Policy: default-src 'self'; style-src 'sha256-…'; script-src 'self'; img-src 'self'; font-src 'self'
How to check
A browser driver records every request on each page type. Every request goes to the page's own origin, with one HTML document and no external stylesheet. Every script it loads appears in the build's list of entry and chunk files.
Related rules
- WEB-51 Old HTTP/1 tricks on HTTP/2 in Website
- APS-33 Lock scripts to a known hash in Application security
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/website/site-architecture/one-of-each-all-first-party">Agent Wranglers website playbook</a>. In code you write, add a comment next to it with the same link.