JSCompress fails to compress my js file - why?


You use the online compression utility jscompress.com to compress your js file but it fails with an error. Why this may be happening and how to fix it.

Possible causes:

Apparently not using open and closing curly brackets in an IF statement would cause this. Well turns out this is not the case. Look at the following example and see if you can figure out what the issue is :-)


function SetupDeliveredVPRecontactNotes($item, id) {
    var theData;

        data: { deliveredVPId: id },
        url: $('#ajaxGetDeliveredVPRecontactNotesUrl').val(),
        type: "GET",
        async: false,
        dataType: "html",
        success: function(data, result) {
            var input = '<textarea class="recontactNote" rows="4" name="DeliveredVPRecontactNotes_' + id + '" id="DeliveredVPRecontactNotes_' + id + '" cols="115">' + data + '</textarea>';
            theData = data;
        error: function(XMLHttpRequest, textStatus, errorThrown) {
            alert("An error occurred: The operation to retrieve the DeliveredVP's Recontact Notes has failed");
    });                  //ajax

    return theData;




The '</textarea>' concatenates text is causing the issue. Replacing it with '</' + 'textarea' fixes the issue.

Print | posted @ Monday, March 22, 2010 8:09 AM

Comments on this entry:

Gravatar # re: JSCompress fails to compress my js file - why?
by Donna Dejuan at 8/19/2013 6:00 PM

jscompress has been outdated and broken in many ways for awhile now. I would avoid using it until the tool is actually fixed. I found a version similar to it that uses UglifyJS2 and the file combining features actually work. It gets regularly updated and has never let me down as of yet. Have been using it for around a year now I think. www.blimptontech.com give it a try especially when your production code should be minified with current library versions.
Post A Comment