I have the following javascript which works fine in debug, but is failing in production due to improper minification:
function buildNotification(config) {
var notificationWrapper = $('<div>', {
'id': _.uniqueId('notification_'),
'class': 'notificationWrapper'
});
var notification = $('<div>', {
'class': 'notification ui-widget ui-state-default'
});
notification.addClass(config.notificationClass);
notification.appendTo(notificationWrapper);
var notificationList = $('<ul/>', {
'class': 'notificationList'
}).appendTo(notification);
// THIS CODE IS IMPROPERLY MINIFIED:
$.each(config.messages, function() {
$('<li/>', {
html: this
}).appendTo(notificationList);
});
return notificationWrapper;
}
The cuplrit being where I set the list item's HTML markup based on config.
The minified mark-up looks like:
function g(a) {
var b = $("<div>", { id: _.uniqueId("notification_"), "class": "notificationWrapper" }), c = $("<div>", { "class": "notification ui-widget ui-state-default" });
c.addClass(a.notificationClass);
c.appendTo(b);
var d = $("<ul/>", { "class": "notificationList" }).appendTo(c);
$.each(a.messages, function() { $("<li/>", { html: this }).appendTo(d); });
return b;
}
And here's the error message I receive:

Could someone drop some knowledge on me? Am I doing something that's bad practice? I ran the code through JSHint, no complaints, and I also have 'use strict' at the top of the file.
UPDATE: I experience the same issue when minifying using Google Closure. The code generated by it is:
function g(a) {
var b = $("<div>", { id: _.uniqueId("notification_"), "class": "notificationWrapper" }), c = $("<div>", { "class": "notification ui-widget ui-state-default" });
c.addClass(a.notificationClass);
c.appendTo(b);
var d = $("<ul/>", { "class": "notificationList" }).appendTo(c);
$.each(a.messages, function() { $("<li/>", { html: this }).appendTo(d); });
return b;
}
This is identical to YUI Compressor.
UPDATE 2: http://jscompress.com/ If I compress my file using this software, it works.
The generated code:
function r(e) {
var t = $("<div>", { id: _.uniqueId("notification_"), "class": "notificationWrapper" });
var n = $("<div>", { "class": "notification ui-widget ui-state-default" });
n.addClass(e.notificationClass);
n.appendTo(t);
var i = $("<ul/>", { "class": "notificationList" }).appendTo(n);
$.each(e.messages, function() { $("<li/>", { html: this }).appendTo(i); });
return t;
}