Articles on: Developers

Host third party CSS and JS locally

The flying_press_selfhost_external_domains filter allows you to customize the list of external domains whose CSS and JS assets are self-hosted by FlyingPress.

By default, these domains are self-hosted:
cdn.jsdelivr.net
cdnjs.cloudflare.com
unpkg.com
code.jquery.com
ajax.googleapis.com
use.fontawesome.com
bootstrapcdn.com
cdn.rawgit.com

You can add or remove domains by using this filter in your theme’s functions.php or using a Code Snippets plugin:

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


Any domain you want to self-host must be visible on the HTML page; resources injected via external JavaScript calls after the page load won't be detected by FlyingPress.

Updated on: 22/10/2024

Was this article helpful?

Share your feedback

Cancel

Thank you!