web essentials - Javascript minifier removes function -


i have js file trying minify having trouble. here file:

$(document).ready(function () { function displaymessage(message, iserror) {     var htmlclass = iserror ? "error" : "success";      $('div.response-message').empty()         .append(message)         .addclass(htmlclass);      $('div.response-message').animate({         top: "-1px"     }, 1000, function () {         alert("donee");     }); }  $('.account-overlay-link > a.link').click(function (e) {     e.preventdefault();     $('.account-overlay.background').removeclass("hide"); });  $('.account-overlay > .area > .close').click(function (e) {     e.preventdefault();     $('.account-overlay.background').addclass("hide"); }); }); 

as can see have regular javascript function @ top , 2 jquery event handlers below. when save file minify, minified file contains 2 jquery handlers function seen.

strangely, if remove 2 jquery blocks leave function in, file still minifies, blank (apart (document).ready) if function not exist.

i have tried recreating file, restarting visual studios, nothing working...

your function not called code inside "ready" handler function, it's being eliminated dead code. nothing outside handler able call anyway.

if want function globally-visible symbol, you'll have explicitly assign property of window object:

$(document).ready(function () { function displaymessage(message, iserror) {     var htmlclass = iserror ? "error" : "success";      $('div.response-message').empty()         .append(message)         .addclass(htmlclass);      $('div.response-message').animate({         top: "-1px"     }, 1000, function () {         alert("donee");     }); } window.displaymessage = displaymessage; 

if that, minifier won't remove it.


Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -