3

I am doing an experimental HTML template wich comes with jquery.min.js file - one of the most popular javascript libraries.

When I load the template from my local hard drive it works fine. When I upload it and load it from server (GWAN) I get error (I think is not the only one) in Chrome looks like this:

Uncaught SyntaxError: Unexpected token { jquery.min.js:3

I inspected a bit and realized there is a

function $

which was turned into

function$

by GWan. The space removed is causing an error in Chrome, Firefox and Safari. I haven't tested other browsers but my IDE also reports a syntax error in the downloaded from GWAN version of the JS file.

I have also tried uploading the files to another server (Apache) and no problem there. The js file was not modified...

Any clues on how to get over this? I suppose there is a bug in javascript on-the-fly optimization of GWan?

Thanks.

Sasho
  • 3,532
  • 1
  • 31
  • 30
  • 1
    Have you tried the dev version of jquery instead of the minified one? – Nagi Jan 31 '14 at 06:19
  • Hi Nagi, a good idea. Just tried it with latest 1.11.0 uncompressed dev and I get the following: Uncaught SyntaxError: Unexpected token ILLEGAL jquery.min.js:4415 line 4415 in the GWan's modified version has the following: "rprotocol=/^\/\rurl=/^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/," While in the original file this are lines 8591 and 8592 containing the following: "rprotocol = /^\/\//, rurl = /^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/," This only comes to confirm that the JS minifyer should be revisited... – Sasho Jan 31 '14 at 12:52

1 Answers1

4

It's a known issue and it will be fixed in next release (soon) You'll be able to disable minifying directly from a init.c script in G-WAN v4.10+, this way:

u8 *www_mini = (u8*)get_env(argv, USE_MINIFYING);
if(www_mini)
{
  *www_mini = 0;
  puts("> disable minifying");
}

You just have to wait for few days for the new v5 release.

Gil
  • 3,279
  • 1
  • 15
  • 25
solisoft
  • 669
  • 4
  • 12
  • Perfect answer, it deserves to be *accepted*. I just wanted to add that minifying is **disabled by default** and we did so because the Javascript syntax is utterly cornershome as compared to C, from which it is inherited. HTML and CSS minifying work fine, to the point that we might offer individual ON/OFF flags in the future. – Gil Jan 31 '14 at 09:02
  • Maybe fixing the minifying would be a better option for the long term. Disabling it would also do as a temporary solution. I looked at and I did not find any 'init.c' file in my entire GWAN tree. If you tell me how to disable it in runtime (or config) from other languages than C (e.g. PHP, JavaScript, Java, ...) in the version you are about to release I will accept this answer. Thank you. – Sasho Jan 31 '14 at 12:38
  • @Gil, I am getting confused. If minifying (what aparantly is causing the problem) is disabled by default why do I get this problem, provided that I did not enable anything in GWan? Thanks. – Sasho Jan 31 '14 at 12:47
  • 2
    They were talking about a newer non-public version of G-WAN, which was only available to certain users. For the time being, since you're just experimenting and not actually using G-WAN in production, run G-WAN _without_ daemon mode - G-WAN will not minify anything (js, css or html). – Nagi Jan 31 '14 at 13:22
  • Thanks Nagi, that did it. Looking forward to a proper fix in the next release of GWan. – Sasho Feb 01 '14 at 13:18
  • 1
    You said 'wait for few days'. April is knocking on the door. When? – Sasho Mar 28 '14 at 15:55