JSMin v1.5 possible bug..

Just downloaded the new JSMin plugin (v1.5), however when I do a 2nd
fwreinit on my site it blows up the css and js.
It appears the jsmin keeps trying it concatenate the compressed file
even though it was already done on the 1st fwreinit.

To fix, I went back and wrapped the code that does concatenation in
the JSMin.cfc (lines 229 - 239) with an IF-ELSE code block. So now it
reads:

// Concatenate Files into a single compressed one
if( arrayLen(compressedFiles) gt 1) {
  sb = createObject("java","java.lang.StringBuilder").init('');
  tempFileName = hash(sb.toString(), "MD5") & "." &
listLast(compressedFiles[1],".");

  for(x=1; x lte arrayLen(compressedFiles); x++){
    sb.append( fileRead(instance.cacheDiskLocation & "/" &
compressedFiles[x]) );
    fileDelete(instance.cacheDiskLocation & "/" & compressedFiles[x]);
  }

  //write out buffer
  fileWrite(instance.cacheDiskLocation & "/" & tempFileName,
trim( sb.toString() ));
  returnAsset = tempFileName;
}
else {
  returnAsset = compressedFiles[1];
}

This IF-ELSE code was in the previous JSMin plugin (v1.4) but was left
out of this new version.

Thanks,
Marcus Cox

Yes we will update soon and test better!

Thanks Luis,

It also appears (at least from my end) that there is a problem with
the content hash approach in that it will use the same name for a js
or css file (overwriting the original) even though the incoming assets
are different. This happens when using minifyToHead in my handlers.
I went back and temporarily replaced it with the previous randomUUID
approach. I still kept the StringBuilder code though.

Thanks!
Marcus Cox

Yes, there is a fix pending for this: create filename after content is aggregated by coldwell · Pull Request #1 · ColdBox/depot-cbox-jsmin · GitHub

Thanks,
Scott

Ok, please re-download version 1.6, I think all is good now.

Luis F. Majano
CEO
Ortus Solutions, Corp
www.ortussolutions.com

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

Social: twitter.com/lmajano facebook.com/lmajano