Customize Slim Rules

When adding rules in Slim (SWIS Performance) to disable, defer, or even delay JS, there is already quite a bit of flexibility. But you want more?? You bet! You may Customize Rules to do all sorts of fancy things. However, what exactly can be accomplished is difficult to explain in a single sentence. So what can you do?

First, you can specify multiple pages, Regular Expressions (regex), and content types. Each of these must be separated by a comma, and you can even mix and match. So you could exclude a couple pages, a content type or two, and even whole sections of your site with a Regex (or three).

Pages

The pages you specify must be exact matches, including slashes. Don't include your domain or the 'https://' portion, only the part of the URL after your site's domain name. For example, if you want to exclude (or include) https://example.com/destinations/paris/, then you would enter only /destinations/paris/.

Regular Expressions

If you want to match multiple pages, that is when regex syntax comes in handy. At the most basic level, if you wanted to match all sub-pages of /destinations/, you could enter /destinations/*. However, full regex syntax is supported, so the possibilities are practically endless.

Note that only exclusions with at least one wildcard (*) will be parsed as a regex. It's a good idea to test/validate your regex syntax to make sure it will work like you think it should.

Content Types

This comes in handy especially if you have custom post/content types (CPT) in WordPress for things like Testimonials, Products, Employees, etc. If you have JS or CSS specific to the display of that CPT, simply enter the "slug" for the custom post type preceded by T>.

For example, on our site we have a CPT for Testimonials, and the slug is "testimonials" so the exclusion would be T>testimonials. If you're not sure what the slug is for a given CPT, click the link in the WP dashboard where you normally view your custom posts. The URL will contain the slug, like /wp-admin/edit.php?post_type=testimonials.

Still need help? Contact Us Contact Us