Script broken by minification (mistaken regex segment for comment)
-
It doesn’t happen when I try the affected code snippet directly on https://www.minifier.org/ but in the context of our site’s js, the resultant file gets one line prematurely truncated because the second regex is being mistaken for a comment, even though it’s perfectly legal JS:
label = input.val().replace(/\\/g, '/').replace(/.*\//, '');
(the minified line ended in
.replace(/.*\
)I don’t know if the problem is upstream with the PHP minifier or something your plugin is doing, but it broke our site because all JS execution on the concatenated file stopped.
The work-around was to disable JS minification (but I still allowed concatenation).
As a side note, I always disable CSS minification as it seems to drop fallbacks like when
display: block;
anddisplay: flex;
exist in the same ruleset. I’d disable it by default if I were you as it’s not obvious in a modern browser that older browsers have lost support.
- The topic ‘Script broken by minification (mistaken regex segment for comment)’ is closed to new replies.