0

Liferay 6.2. tries to use best practices and JS minification is one of them.

But what do you do when your unminified JavaScript works and minification produces errors like this (in Tomcat console):

12:23:48,794 ERROR [http-bio-8080-exec-10][MinifierUtil:111] 607: 21: identifier is a reserved word
12:23:48,797 ERROR [http-bio-8080-exec-10][MinifierUtil:111] 608: 45: identifier is a reserved word
12:23:48,802 ERROR [http-bio-8080-exec-10][MinifierUtil:111] 1: 0: Compilation produced 2 syntax errors.
12:23:48,805 ERROR [http-bio-8080-exec-10][MinifierUtil:88] JavaScript Minifier failed for_________    AUI().use('node', 'aui-base', 'aui-io-request', 'aui

[MinifierUtil:111] 607: 21: and [MinifierUtil:111] 608: 45: are not line numbers in your code (jsp/ftl/...) as man expects from console log and googling "identifier is a reserved word" or "JavaScript Minifier failed for_________" helped me almost nothing (ok, I knew about https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#Keywords normally).

Pasting code between <script> and </script> to JS lint or hint or any other JS tool is not an option as it contains many JAVA and spring/freemarker/liferay tags etc...

So - my question is - as I wasn't able to find best practices / methodologies for debugging this - what is your opinion (or even better - experience :)) ?

2 Answers 2

1

Well, you solved the problem in another way - just some pointers should you (or someone else) run into this issue again:

Minifier reports Line number and Offset in these error messages, but they're related to the content that the minifier sees - e.g. not in your JSP, FTL or other file, but in whatever gets passed to the minifier.

The way to read the minifier log is:

  • Line 607, column 21 as well as Line 608, column 45 have a problem
  • In the following line, you see JavaScript Minifier failed for_________ AUI().use('node', 'aui-base', 'aui-io-request', 'aui which is the first part of the content that the minifier sees - locating this code, you might be able to identify which content gets passed to the minifier and count down the lines (well, jump down 607 lines from there)

Side issues: Agreeing with @Origineil that the startup time rather points to another issue that you have - it shouldn't be that much unless you deliberately have processes running at startup. E.g. if you're running a cluster and each machine keeps its own lucene index, you must reindex at startup. If you want to work around that, two indexes might not be what you're after. But it's only an example, and you didn't ask for this. I just wanted to add some pointers. I assume that you have tuned your JVM memory settings already and are not running with the default bundle's settings?

Sign up to request clarification or add additional context in comments.

4 Comments

Thank you very much, Olaf. so - if my Javascript was inserted directly in ftl I should "extract" that and find line number? Abou side issues - yes - no tweaking or modifying took place from my part - because I want same enviroment as others in my group - so default from Liferay is used. I know speed can be better on Linux systems (I like to believe that based on better file system) but it was easier for me to just save and run default in windows. If you agree - I can open that side issues in a seperate question - so others can find it easier? Thanks.
about js in ftl: yes, that's my expectation from what I see in MinifierUtil.java. There's still a slight chance that it's concatenated script code, e.g. a combination of many different script parts - then it will be harder again to locate the proper line number. If minifier fails, it will deliver the content unminified, this might help you.
With regards to opening other questions: As Stackoverflow is about programming, not so much about server maintenance and tuning, you might have some pushback here. If you manage to ask those questions from a programming background, you're safe. Otherwise you might want to try serverfault.com or the forums on liferay.com/community/forums
Thanks again. Will do (first I will try to investigate more in depth and provide some param's for constructivity).
0

I finally managed to solve the problem by:

copying the rendered (and unminified(!)) code between <script> and </script> and paste it to JShint/lint/online minifier and re-check it there,

but I still wonder if there is some better way... (changing server properties from developer to production and back means restarting server few times at least and that takes about 300 seconds (only for restart) on my new(!) i7 vPro 64GB, SSD HDD workstation, so I try to avoid it as much as I can :)).

BTW: unminified code had some "deprecated" but simple ECMA methods that worked normally in JSFiddle and all latest browsers on my Win8.1...

2 Comments

300 seconds for that machine spec feels wrong. Are you trimming the development runtime environment down to the minimum required. By only for restart I assume you mean using that menu option. I haven't had an issue insta-killing (terminate button within the console of Liferay Developer Studio) the server and then performing a start. My start times average 100 seconds on a "new" machine. The core 2 duo / 4gig ram machine I was provided when I first started ( I promptly asked for an upgrade) could boot a clean tomcat bundle in 300 seconds.
Thanks, yes, I also feel it takes too long :) Well, dev env is default 6.2. EE + one theme + few "lightweight" portlets I am working with. Those do not add weight because I remember default, out of box env took about the same, maybe 5-10% less... Measuring time - I just run start.bat (Win ;)) and wait for INFO: Server startup in 416811 ms (yes, this one took 416s). As front-end oriented and new to JAVA (worked with PHP before) I was really frustrated with all the deployments (also taking about a min) until I learned about developer mode (that allows "refresh based developement" :))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.