• 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

    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)
  • Plugin Support Silvena Koleva

    (@silvenatodorova)

    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!

    Thread Starter Matthias Günter

    (@mguenter)

    Hi again @silvenatodorova !

    Nice! I want to do some tests with our plugin. Is it possible to get a developer license without any costs? ??

    Plugin Support Silvena Koleva

    (@silvenatodorova)

    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

    Let us know if you need any further information regarding NitroPack.

    Best regards!

    Thread Starter Matthias Günter

    (@mguenter)

    Hi again @silvenatodorova !

    Thanks for your follow-up.

    Is there an API in PHP to flush the cache?

    Regards
    Matthew ??

    Plugin Support Nikol @ Nitropack

    (@nitronikol)

    Hello @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/

    Hope this information helps!

    Thread Starter Matthias Günter

    (@mguenter)

    Hi again @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

    Regards,
    Matthew ??

    Thread Starter Matthias Günter

    (@mguenter)

    Hey @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.