Title: Exclude inline scripts and dynamic assets
Last modified: April 1, 2022

---

# Exclude inline scripts and dynamic assets

 *  [Matthias Günter](https://wordpress.org/support/users/mguenter/)
 * (@mguenter)
 * [4 years, 2 months ago](https://wordpress.org/support/topic/exclude-inline-scripts-and-dynamic-assets/)
 * Hey NitroPack Team!
 * Here is Matthew, developer behind the plugin of “Real Cookie Banner”.
 * We are trying to make Real Cookie Banner compatible with NitroPack. For this,
   we need to exclude inline scripts and dynamically created assets from any NitroPack
   operations (minify, combine, …).
 * On your website, you have an interesting article about how to exclude resources:
   [https://support.nitropack.io/hc/en-us/articles/1500002527542-Excluded-Resources](https://support.nitropack.io/hc/en-us/articles/1500002527542-Excluded-Resources)
 * Unfortunately, this doesn’t work for us because we can’t have all of our customers
   create a rule. It would be more practical to have an identifier here which is
   always excluded. Is there a chance you introduce an identifier like the following,
   which is always skipped on your end:
 *     ```
       <script nitropack-skip>console.log("do anything");</script>
       <script nitropack-skip src="https://example.com/my-asset.js"></script>
       ```
   
 * Regards,
    Matthew 🙂

Viewing 7 replies - 1 through 7 (of 7 total)

 *  [Silvena Koleva](https://wordpress.org/support/users/silvenatodorova/)
 * (@silvenatodorova)
 * [4 years, 2 months ago](https://wordpress.org/support/topic/exclude-inline-scripts-and-dynamic-assets/#post-15523523)
 * Hi Matthew,
 * Thank you for your interest in NitroPack! We have good news for you – this option
   already exists. 🙂
 * The attribute is `nitro-exclude` and everything else is the same as your example.
   It also works on all types of resources, not only JS.
 * Regards!
    -  This reply was modified 4 years, 2 months ago by [Silvena Koleva](https://wordpress.org/support/users/silvenatodorova/).
 *  Thread Starter [Matthias Günter](https://wordpress.org/support/users/mguenter/)
 * (@mguenter)
 * [4 years, 2 months ago](https://wordpress.org/support/topic/exclude-inline-scripts-and-dynamic-assets/#post-15523681)
 * Hi again [@silvenatodorova](https://wordpress.org/support/users/silvenatodorova/)!
 * Nice! I want to do some tests with our plugin. Is it possible to get a developer
   license without any costs? 😊
 *  [Silvena Koleva](https://wordpress.org/support/users/silvenatodorova/)
 * (@silvenatodorova)
 * [4 years, 2 months ago](https://wordpress.org/support/topic/exclude-inline-scripts-and-dynamic-assets/#post-15528990)
 * Hello Matthew,
 * Thanks for asking! We haven’t got a developer license, but you can use our free
   plan instead: [https://support.nitropack.io/hc/en-us/articles/360062731413-NitroPack-s-Free-Plan](https://support.nitropack.io/hc/en-us/articles/360062731413-NitroPack-s-Free-Plan)
 * Let us know if you need any further information regarding NitroPack.
 * Best regards!
 *  Thread Starter [Matthias Günter](https://wordpress.org/support/users/mguenter/)
 * (@mguenter)
 * [4 years, 2 months ago](https://wordpress.org/support/topic/exclude-inline-scripts-and-dynamic-assets/#post-15539013)
 * Hi again [@silvenatodorova](https://wordpress.org/support/users/silvenatodorova/)!
 * Thanks for your follow-up.
 * Is there an API in PHP to flush the cache?
 * Regards
    Matthew 😃
 *  Plugin Support [Nikol @ Nitropack](https://wordpress.org/support/users/nitronikol/)
 * (@nitronikol)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/exclude-inline-scripts-and-dynamic-assets/#post-15544163)
 * Hello [@mguenter](https://wordpress.org/support/users/mguenter/) ,
 * The easiest way to do it would be with a cron job along with WP CLI. The command
   itself for WP CLI would be:
    `wp NitroPack purge --purge-url=https://domain.com/
   page`
 * Then the cron job, for example, once a day:
    `0 0 * * * /path/to/wp-cli/wp --
   path=/path/to/your/website NitroPack purge --purge-url=https://domain.com/page`
 * The paths in the cron job would need to be adjusted based on where WP CLI is 
   installed on the server, and the path to your website as well.
    This should be
   fairly straightforward to set up if you check with your hosting’s support.
 * Alternatively, you can integrate our API in a PHP script by following our documentation
   here:
 * > [https://docs.nitropack.io/](https://docs.nitropack.io/)
 * Hope this information helps!
 *  Thread Starter [Matthias Günter](https://wordpress.org/support/users/mguenter/)
 * (@mguenter)
 * [4 years ago](https://wordpress.org/support/topic/exclude-inline-scripts-and-dynamic-assets/#post-15675142)
 * Hi again [@nitronikol](https://wordpress.org/support/users/nitronikol/) !
 * Sorry, but I have to open the ticket again.
 * I have now implemented the exclude so far, and it works quite well. Unfortunately,
   no inline scripts created with `wp_localize_script` can be excluded.
 * Why? WordPress does not offer a filter to modify the `<script` tag via e.g. `
   script_loader_tag`. Is there also a directive to exclude this within an inline
   script?
 * Example:
 *     ```
       <script id="myhandle-js-extra">
         var myHandle = /* nitro-exclude */ {};
       </script>
       ```
   
 * Or do you have any other idea? Otherwise, we need to add the following rule to
   NitroPack:
 * > [flameshot_screenshot](https://imgur.com/iiO3EXW)
 * Regards,
    Matthew 🙂
 *  Thread Starter [Matthias Günter](https://wordpress.org/support/users/mguenter/)
 * (@mguenter)
 * [4 years ago](https://wordpress.org/support/topic/exclude-inline-scripts-and-dynamic-assets/#post-15709805)
 * Hey [@nitronikol](https://wordpress.org/support/users/nitronikol/) !
 * More and more customers are asking for compatibility with NitroPack, but we need
   to exclude the inline script without tag, but with a comment in the inline script
   itself. Any chance to implement something like this? 🙂

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Exclude inline scripts and dynamic assets’ is closed to new replies.

 * ![](https://ps.w.org/nitropack/assets/icon-256x256.gif?rev=2936590)
 * [NitroPack – Performance, Page Speed & Cache Plugin for Core Web Vitals, CDN & Image Optimization](https://wordpress.org/plugins/nitropack/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/nitropack/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/nitropack/)
 * [Active Topics](https://wordpress.org/support/plugin/nitropack/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/nitropack/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/nitropack/reviews/)

 * 7 replies
 * 3 participants
 * Last reply from: [Matthias Günter](https://wordpress.org/support/users/mguenter/)
 * Last activity: [4 years ago](https://wordpress.org/support/topic/exclude-inline-scripts-and-dynamic-assets/#post-15709805)
 * Status: not resolved