Skip to main content

Customize Self-Hosted Domains for Third-Party CSS and JS

Updated over a month ago

FlyingPress can automatically self-host CSS and JavaScript files from trusted external domains. This improves performance by reducing DNS lookups and avoiding third-party blocking or delays.

You can customize the list of domains using the flying_press_selfhost_external_domains filter.

Default domains automatically self-hosted

FlyingPress self-hosts assets from the following domains by default:

  • cdn.jsdelivr.net

  • cdnjs.cloudflare.com

  • unpkg.com

  • code.jquery.com

  • ajax.googleapis.com

  • use.fontawesome.com

  • bootstrapcdn.com

  • cdn.rawgit.com

Where to add this code

Add the filter in:

  • Your theme’s functions.php file

  • A custom plugin

  • A plugin like Code Snippets

Example: Add more domains to self-host

add_filter('flying_press_selfhost_external_domains', function ($domains) {
$domains[] = 'example-cdn.com';
$domains[] = 'another-cdn.com';
return $domains;
});

You can also remove domains by modifying or filtering the $domains array accordingly.

Notes

  • The domain must be present in the HTML output at page load

  • Resources injected via JavaScript after page load won’t be detected or self-hosted

  • Only CSS and JS files are considered—no images, fonts, or other resources

Did this answer your question?