• Resolved barold01

    (@barold01)


    Is there any way to exclude certain scripts from being minified/optimized by Phastpress?

    The plugin is fantastic, but unfortunately it breaks the Google Tag Manager script on my site.

    If I disable the “Minify scripts and improve caching” option, GTM works.

    Ideally, it would be possible to exclude a script from being optimized, is this possible currently?

    • This topic was modified 5 years, 9 months ago by barold01.
    • This topic was modified 5 years, 9 months ago by barold01.
Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Albert Peschar

    (@kiboit)

    Hi Barold,

    Thank you for trying out PhastPress.

    Unfortunately, it’s not yet possible to exclude scripts from optimization. On the other hand, Google Tag Manager should work nevertheless, even with PhastPress enabled.

    If you share the URL to your site, I could take a look and perhaps find out why it doesn’t work with script optimization enabled.

    –Albert

    Thread Starter barold01

    (@barold01)

    Hey Albert,

    Thanks for the reply.

    The site in question is https://moodle.com/

    Currently, the “Minify scripts and improve caching” setting is off.
    If you check the console on the homepage, you’ll notice a console log saying “tag fired”, which is a test tag from GTM.

    As soon as I turn the minify setting on that tag stops firing, which I assume means that GTM has stopped working.

    Thanks ??

    Plugin Author Albert Peschar

    (@kiboit)

    Hi Barold,

    I’ve testing your GTM script on a local install of PhastPress, and I’m not seeing the same problem, unfortunately.

    There is in fact a way to exclude scripts, but it requires editing the source code:

    Would you be able to adjust the <script> tag to contain a data-phast-no-defer attribute? For example: <script data-phast-no-defer> (GTM code here) </script>. That should disable Phast for that particular script.

    –Albert

    Plugin Author Albert Peschar

    (@kiboit)

    P.S.: I would recommend turning off other optimization software (except caching), such as WP Rocket and Cloudflare Rocket Loader, since those can conflict with PhastPress, and don’t offer important added functionality.

    Thread Starter barold01

    (@barold01)

    Thanks Albert, the data-phast-no-defer attribute worked perfectly!
    Much appreciated!

    Plugin Author Albert Peschar

    (@kiboit)

    Barold,

    I’m happy to hear that.

    I have one additional tip for you: if I turn off JavaScript, the content of the page doesn’t render. See: https://peschar.net/s/uIZwNqp108wl02EhPgDe/

    That might be due to some animations in the theme, or some kind of lazy loading plug-in. In any case, if you change this so that the page can render without JavaScript, it will improve the perceptual load speed of the page enormously.

    –Albert

    Thread Starter barold01

    (@barold01)

    Hey Albert,

    Hope you’re well.
    I wanted to bring to your attention another issue related to scripts.

    The site we discussed above (https://moodle.com) uses a theme running the WPBakery (previously Visual Composer) page builder.

    WPBakery seems to rely on 2-3 bits of javascript in order to begin generating page content.

    As I understand, Phastpress delays loading of all javascript until page load is complete. This causes WPBakery to not begin loading page content until very late.

    Despite Pagespeed Insights scores remaining quite high, this causes a huge negative impact on perceived load time.

    I don’t know if there’s a way to directly access the WPBakery scripts in order to add the “data-phast-no-defer” attribute!

    So, I’ve had to disable Phastpress and move to another plugin for now.

    A method within Phastpress to exclude specific theme/plugin scripts from being deferred (by name, or by directory, etc) without having to directly modifying the plugins themselves, would solve the issue – I don’t know if such a feature if possible!?

    Thanks again,

    Plugin Author Albert Peschar

    (@kiboit)

    Hi Barold,

    Thanks for the report, and your detailed analysis.

    Rendering shouldn’t be dependent on JavaScript (at least most of it), otherwise you’ll get this problem.

    It would be possible to add the feature you describe (excluding scripts based on name or path). However, this goes against the zero configuration approach PhastPress attempts to take. Furthermore, when you exclude certain scripts, you are likely to run into problems regarding dependencies. For instance, WP Bakery might require jQuery, and it’s not possible to keep track of this automatically.

    For now, it’s not something I’m planning to implement.

    –Albert

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Exclude scripts – is there a way?’ is closed to new replies.