I tried JSMin+ and Advagg and it broke my javascript. As noted by a comment on the JSMin+ 1.4 release page, its compressed scripts can break when they are aggregated.
http://crisp.tweakblogs.net/blog/6861/jsmin%2B-version-14.html#r_120294

The problem is that JSMin+ does not append a closing semi-colon to the end of a file when it should. So if the 1st script ends with a function call (last character a closing bracket) and the 2nd script begins with a closure (first character an opening bracket), the two are appended together as if it is one big function call and things go haywire.

Seeing as the above comment is almost a year old and there are no signs that it will ever be fixed in JSMin+ I patched Advagg to work around it and append a closing semi-colon to the end of a compressed file whenever it is needed.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mikeytown2’s picture

Status: Needs review » Fixed
FileSize
712 bytes
759 bytes

Following patches have been applied to 6.x & 7.x. I decided to use strpbrk as accessing the string as an array always seems a little hacky.

mikeytown2’s picture

Fix for jsmin as well. Applied to D6. Patch for D7 in #1 works for all 3 compressors.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

RaulMuroc’s picture

To me for D7 doesn't apply neither stable version nor dev version. :S This is reviewed & tested by community?

Following error is shown:

Checking patch advagg_js_compress/advagg_js_compress.advagg.inc...
error: while searching for:
$contents = jsmin($contents);
}

// Cache minified data for at least 1 day.
cache_set($cache_id, $contents, 'cache_advagg_info', REQUEST_TIME+86400);
}

error: patch failed: advagg_js_compress/advagg_js_compress.advagg.inc:207
error: advagg_js_compress/advagg_js_compress.advagg.inc: patch does not apply

mikeytown2’s picture

@RaulMuroc
Latest release came out on 2013-Dec-30; this was applied on 2013-Dec-24. Patch is failing because it is not needed; code changes from this issue were included in the main release as it was committed as stated in #1 :)

You can also verify that the code is in by looking at the git shortlog and finding the commit message