• The Autoptimize JavaScript minification process incorrectly transforms string literals inside JavaScript code, breaking expected runtime behavior. In particular, string arguments passed to functions are modified during minification, resulting in invalid logic and runtime errors in the browser.

    Original code (before minification):

    let r=()=>.${(t.params.wrapperClass||).trim().split( ).join(.)}

    Minified / transformed code (after Autoptimize):

    let r=()=>.${(t.params.wrapperClass||).trim().split().join(.)}

    Issue

    The minifier incorrectly transforms:

    .split()

    into:

    .split()

    This changes the logic from splitting a class string by spaces into splitting it into individual characters.

    Impact

    This leads to invalid CSS class selectors such as:

    .s.w.i.p.e.r.-.w.r.a.p.p.e.r

    which causes runtime errors like:

    Failed to execute 'matches' on 'Element': '.s.w.i.p.e.r.-.w.r.a.p.p.e.r' is not a valid selector

Viewing 2 replies - 1 through 2 (of 2 total)
  • Oops.

    Original code (before minification):
    let r=()=>.${(t.params.wrapperClass||).trim().split( ).join(.)}

    Minified / transformed code (after Autoptimize):
    let r=()=>.${(t.params.wrapperClass||).trim().split( ).join(.)}

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    Hey Sergei;
    Afraid the example code in your 2nd post might have been “cleaned up” as well, adding code here can be difficult at times 😉

    That being said; the JS minifier is a 3rd party component (js-min.php by MrClay) for which development unfortunately seems to have grinded to a halt and I’m way to unknowledgable of the internals of the code to even think about trying to fix the issue described. I might look into an alternative PHP minifier, but for now I would suggest to exclude the JS from minification to avoid such problems?

    best,
    frank

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

You must be logged in to reply to this topic.