CDN Domain Rewriting

What's a CDN?

Put simply, a CDN is a global network of super-fast servers that are designed for a single purpose: delivering assets, and doing it ultra-fast. "Assets" meaning any JS, CSS, images, fonts, and what not else that your page loads. If you have a super fast server already, and your audience is mostly in one location, you probably don't need a CDN. But for many sites, a CDN can be a nice speed boost, and they are super cheap these days. We use and recommend BunnyCDN or our Easy IO service which is built on top of BunnyCDN.

Power Tools

By default, SWIS will rewrite URLs for all resources: JS, CSS, fonts, images, etc. Of course, you can add various exclusions, all the way from excluding single images, to entire folders. Wildcards are implied, as SWIS just uses plain string matching. In other words, if you exclude "awesome", and have an image named "my-awesome-image.jpg", that image will be excluded.

If you want to customize things further, there are a host of filters available for developers:

apply_filters( 'swis_skip_cdn_by_page', false, $uri );
apply_filters( 'swis_cdn_allowed_domains', $allowed_domains );
apply_filters( 'swis_cdn_the_page', $content ); // Runs after the CDN parser, so that you can mangle the content yourself when we're done with it.
apply_filters( 'swis_allowed_background_image_elements', array( 'div', 'li', 'span', 'section', 'a' ) );
apply_filters( 'swis_cdn_skip_image', false, $src, $tag ) // $src being the image URL, and $tag being the entire tag, be it an img, div, span, etc.
apply_filters( 'swis_cdn_skip_url', false, $url ); // Applies to JS, CSS, and images.
apply_filters( 'swis_cdn_development_mode', false ); // Return true to completely shut off the CDN rewriter. Can be useful on staging sites after you clone from production.