• Resolved Alexander Guskov

    (@forcesail)


    Hello,
    I have to report another issue of your amazing plugin.

    Merging JS to goes almost well until set both
    +?Enable merging of JavaScript files??
    + Contain each included file in its own block?

    This case file from wp_enqueue_script goes to it’s own and separate block, wp_localize_script with the same handle goes to another block and wp_add_inline_script with the same handle keeps left in the html file.
    So, the script from wp_enqueue_script file doesn’t see variables from wp_add_inline_script and wp_localize_script and can’t be executed.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support vupdraft

    (@vupdraft)

    Hi Alexander,

    The “contain each included file in it’s own block” is only really intended for troubleshooting when you are trying to isolate a script that is causing issues during minification/merging. I would not enable this unless you need to.

    Thread Starter Alexander Guskov

    (@forcesail)

    Hi,
    it’s true, but it makes that it can’t be troubleshooting anything because some scripts definitely won’t work, even that ones that work without “blocking”.
    I suppose that all scripts with same handle, that comes from there 3 functions should be encapsulated in one block.

    Plugin Support vupdraft

    (@vupdraft)

    Hi Alexander,

    Apologies, I realise that this must be frustrating. Unfortunately this is the way the functionality is designed to work (i.e to separate the various files)

    Thread Starter Alexander Guskov

    (@forcesail)

    Hi Vupdraft,

    I’m afraid that I didn’t explain the problem clear enough:
    Both wp_localize_script and wp_add_inline_script don’t add any file to be linked but DO some INJECTIONS (or add some additions) to the already added files by wp_enqueue_script, absolutelly connected to that has added by wp_enqueue_script by handle and can’t exists separately.
    So, divide the entire and indivisible to the separate blocks is to definitely and deliberately make all, that included with the one handle unworkable.

    I’m afraid but it should be included in the same block OR both, that injected by wp_localize_script and wp_add_inline_script should NOT be encapsulated in any {} blocks.

    Plugin Contributor Venkat Raj

    (@webulous)

    @forcesail I was partially able to reproduce the issue.

    i.e. When using wp_localize_script it is added in a separate script tag and is not resulting in a error. However, if using wp_add_inline_script WP-Optimize adds separate try/catch block which is a bug and results in the error you mentioned. Thanks for reporting.

    I’ve added this to our to do list. A fix will be available in the next release.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Merging JS in blocks error’ is closed to new replies.