• Resolved Hector Cabrera

    (@hcabrera)


    Hi Raul,

    Is there any chance Fast Velocity Minify could exclude application/json scripts from the minification process?

    WordPress Popular Posts version 5.2 injects a application/json script into <head> that contains a JSON string, for example:

    <script type="application/json" id="wpp-json"
    {"sampling_active":0,"sampling_rate":"100","ajax_url":"https:\/\/www.example.com\/wp-json\/wordpress-popular-posts\/v1\/popular-posts","ID":false,"token":"a787dd82b4","lang":null,"debug":true}
    </script>

    When Fast Velocity Minify is active, this inline application/json script is apparently bundled with the rest of the minified code, breaking WordPress Popular Posts’ ability to track pageviews, load widgets, etc.

    application/json script tags should be safe to ignore as the browser doesn’t execute any code (they’re just JSON strings) and won’t load (external) JS files either.

    Other solutions I tested (like Autoptimize) do seem to ignore these <script type="application/json">...</script> tags so I’m hoping you could implement this as well.

    Thanks in advance!

Viewing 1 replies (of 1 total)
  • Plugin Author Raul P.

    (@alignak)

    That is because, the plugin doesn’t know if the script is json or whatever. It captures the file and it’s dependencies.

    Other plugins, they capture the html instead of looking at the $wp_scripts variable, and that’s why they can filter those out. They also use a list of keywords that should not be merged in some situations.

    I’ll look into this and for the next update, I should have a solution for this.
    Thanks for reporting

    For now, you would have to add the parent js file to the ignore list, and then the code dependency won’t be merged as well.

Viewing 1 replies (of 1 total)
  • The topic ‘Exclude application/json scripts from minification?’ is closed to new replies.