留言板

How to debug Javascript Minify

thumbnail
Javier Solana,修改在6 年前。

How to debug Javascript Minify

Junior Member 帖子: 59 加入日期: 14-6-26 最近的帖子
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
thumbnail
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!
thumbnail
Javier Solana,修改在6 年前。

RE: How to debug Javascript Minify

Junior Member 帖子: 59 加入日期: 14-6-26 最近的帖子
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
thumbnail
Amos Fong,修改在6 年前。

RE: How to debug Javascript Minify

Liferay Legend 帖子: 2047 加入日期: 08-10-7 最近的帖子
You could disabling it to see if it's really your issue. See https://web.liferay.com/community/forums/-/message_boards/message/25412043
thumbnail
Javier Solana,修改在6 年前。

RE: How to debug Javascript Minify

Junior Member 帖子: 59 加入日期: 14-6-26 最近的帖子
It was a matter of how a part of the code was being minified. I was using setInterval for creating an animtaion effect:

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.