I have a function:
function createAddressList(url) {
$.ajax({
url: url,
cache: false,
async: true
}).done(function (msg) {
alert("Data Saved: " + msg);
});
}
which translates minified to:
function g(b){a.ajax(http://localhost/testpage/b,cache:!1,async:!0).done(function(a){alert("Data Saved: "+a)})}
this results in an error,
chrome :
Uncaught SyntaxError: Unexpected token :
Firefox:
SyntaxError: missing ) after argument list
...ion g(b){a.ajax(http://localhost/testpage/b,cache:!1,async:!0).done(f
How can I solve this? Help is much appreciated
Use mangle option to make exceptions when renaming $ to jQuery:
1) Use jQuery instead $
function createAddressList(url) {
jQuery.ajax({
url: url,
cache: false,
async: true
}).done(function (msg) {
alert("Data Saved: " + msg);
});
}
2) Config Uglify
grunt.initConfig({
uglify: {
options: {
mangle: {
except: ['jQuery']
}
},
my_target: {
files: {
'dest/output.min.js': ['src/input.js']
}
}
}
});