留言板
How to debug Javascript Minify
Hi,
we are facing some problems when deploying a portlet in production.
The $( document ).ready(function() { ... }); in Javascript file is not being executed. No error anywhere...
I think it is due to the Javascript Minify in Liferay, but I need help to debug the problem, since no error appears anywhere.
Locally, with Eclipse, everything works perfectly.
Thanks in advance
we are facing some problems when deploying a portlet in production.
The $( document ).ready(function() { ... }); in Javascript file is not being executed. No error anywhere...
I think it is due to the Javascript Minify in Liferay, but I need help to debug the problem, since no error appears anywhere.
Locally, with Eclipse, everything works perfectly.
Thanks in advance
David H Nebinger,修改在6 年前。
RE: How to debug Javascript Minify
Liferay Legend 帖子: 14916 加入日期: 06-9-2 最近的帖子
You should not be using the $ alias for the javascript library. Too easy to end up with a namespace collision. Stick with the real name whether it is jquery or aui or ... and avoid the $.
Come meet me at the 2017 LSNA!
Come meet me at the 2017 LSNA!
David H Nebinger:
You should not be using the $ alias for the javascript library. Too easy to end up with a namespace collision. Stick with the real name whether it is jquery or aui or ... and avoid the $.
Come meet me at the 2017 LSNA!
Thanks David for the response, but that is not my problem, $ and jQuery is exactly the same in my environment:
> $ === jQuery
true
You could disabling it to see if it's really your issue. See https://web.liferay.com/community/forums/-/message_boards/message/25412043
It was a matter of how a part of the code was being minified. I was using setInterval for creating an animtaion effect:
I juist removed this effect and everything works perfectly, since I didn't manage to understand why the minifying process didn't like this part.
var id = setInterval(frame, 10);
function frame() {
if (barCompleted[0]&&barCompleted[1]&&barCompleted[2]&&barCompleted[3]&&barCompleted[4]&&barCompleted[5]&&barCompleted[6]) {
clearInterval(id);
} else {
for (var i = 0; i < pillars.length; i++) {
$circle = $('#svg_'+pillars[i]+' #bar_'+pillars[i]);
myTimer = document.getElementById("timer_"+pillars[i]);
if(showValue >= val[i]){
barCompleted[i]=true;
myTimer.textContent = val[i];
}else{
$circle.css({ strokeDashoffset: ((100-showValue)/100)*c});
myTimer.textContent = showValue;
showValue++;
}
}
}
}
I juist removed this effect and everything works perfectly, since I didn't manage to understand why the minifying process didn't like this part.