Files

35 lines
2.1 KiB
Markdown
Executable File

# CDN
**Dotjuice → Page speed → CDN**
## What this tab controls
Rewriting your site's stylesheet and script URLs to point at a CDN hostname instead of your own server.
## Settings
| Setting | Default | What it does |
|---|---|---|
| **Enable CDN URL Rewriting** | Off | Turns URL rewriting on or off. |
| **CDN URL** | Empty | The hostname to rewrite asset URLs to (e.g. `https://cdn.yoursite.com`). The plugin doesn't check that this URL is reachable or correctly configured — make sure your CDN is already set up and serving your site's files before enabling this. |
| **Rewrite These Directories** | `wp-content, wp-includes` | Only URLs containing one of these path segments are rewritten — leaves this as-is unless you have a specific reason to narrow or widen it. |
## What this does and doesn't cover
This setting rewrites the URLs WordPress generates for enqueued stylesheets and scripts — the same files covered by the [CSS](css-optimisation.md) and [JavaScript](javascript-optimisation.md) tabs. It does **not** rewrite:
- Image URLs (`<img>` tags, background images set via CSS)
- Media Library files linked or embedded in post content
- Fonts referenced from inside a CSS file's own `@font-face` rules
If your goal is CDN delivery for your whole media library rather than just CSS/JS, you'll need a dedicated media-offload plugin, or your CDN provider's own integration, in addition to this setting.
## Setting it up
1. Confirm your CDN is already configured and correctly mirroring/proxying your site (this plugin doesn't set up the CDN itself — it only rewrites URLs to point at one that's already working).
2. Enter your CDN's hostname in **CDN URL**, including the `https://` prefix.
3. Enable **Enable CDN URL Rewriting** and save.
4. Clear your cache and check a page's source (or your browser's Network tab) to confirm stylesheet and script URLs now point at your CDN hostname and load correctly.
If assets fail to load after enabling this, double-check the CDN URL is exactly correct and that your CDN is actually serving the `wp-content`/`wp-includes` paths — a misconfigured CDN will show as broken styling or a console full of failed requests.