Excluded Resources

With the “Excluded Resources” feature, you can tell NitroPack not to optimize:

 1. CSS and JavaScript

 2. Fonts

 3. Images

To do so, you need to enable the feature from the General Settings panel and fill out a bit of information.

Excluded_Resources_Clean.png

Asset URL/Code

For external resources, you must enter the resource URL.

For inline resources, write down a single line of code that’s unique to the resource. NitroPack will recognize the line and exclude the entire resource.

Also, don’t include the <script> or <style> tag.

For example, to exclude this inline script:

Example_Code3.png

 

Skip the <script> tags.

Example_Code4.png

 

And choose one line of code that’s unique to the resource.

 

You can use the wildcard symbol * to match more than one resource with a single rule or to avoid writing the entire snippet.

In our example, we can exclude the script by entering document*cta-btn instead of the entire line of code.

 
You can also use wildcards to exclude all resources containing the same word in their name.
 
For example, if you don’t want PNG images to be optimized by NitroPack, you can add the following exclude rule:
 
Excluded_Resources_Example.png

 

If you have resources with dynamic parts in them (like dynamic URLs), you can also use the wildcard to match their dynamic parts.

In the example above, adding * in front of ".png" includes all paths that end in ".png" while adding it after it includes all paths that have text after ".png". The combination of the two covers any path that includes ".png".

Resource Type

Next, you can choose between the resource types we mentioned above.

Excluded_Resources_3.png

Resource Relation

You can also specify if the resource is external or inline.

Excluded_Resources_4.png

An external resource is anything specified by the <src> or href (for external CSS) attributes. Conversely, an inline resource is located in the HTML markup. The first example in this article shows how to exclude an inline script.

Device

By default, the resource will be excluded from optimization on all devices. You can also exclude it only for certain devices.

Excluded_Resources_5.png

For instance, if you select “Mobile”, the specified resource will be optimized only on Desktop and Tablet devices.

Excluded Operations

If you don’t select an excluded operation, NitroPack will ignore the resource. It’ll be excluded from all forms of optimization, including our resource loading strategy.

You can change that by choosing one or more operations that you don’t want to be performed.

Excluded_Resources_6.png

 

For more information on each of these, check out our article on Excluded Operations.

After filling out all the fields, remember to save your settings.

 

Was this article helpful?
4 out of 9 found this helpful

Comments

0 comments

Please sign in to leave a comment.