Reputation: 34152
I'm already using bundling and minification but there are some javascript code in each page that they also contain server-side <% %>
tags. I tried online javascript compressors but they just remove these tags and everything inside them.
Is there a way to this?
sample code:
if('<%=id%>'=='0'){
$.get('/ajax/getnameinfo.aspx?l=<%=Settings.LanguageID%>&n=' + $('#name').val(), function (d) {
$('.wait').remove();
var a = $(d).children().first();
if (a.length == 0) {
} $('form').submit();
});
}
Upvotes: 1
Views: 49
Reputation: 462
Put this somewhere on your generated page:
window._server = {id: '<%=id%>', languageId: '<%=Settings.LanguageID%>'};
and modify JS into:
if(_server.id=='0'){
$.get('/ajax/getnameinfo.aspx?l='+_server.languageId+'&n=' + $('#name').val(), function (d) {
$('.wait').remove();
var a = $(d).children().first();
if (a.length == 0) {
} $('form').submit();
});
You can replace _server with any variable that's explicitly bound to js file. You may additionally consider using external data source (an object passed to a constructor) in case you want to use your javascript with both asp-driven and js-driven parameters.
Upvotes: 2