Pergunta

When minifying JavaScript in the handy tool by Google called Closure Compiler it gives the following error (and doesn't minify a thing):

Number of errors: 1 JSC_TRAILING_COMMA: Parse error. IE8 (and below) will parse trailing commas in array and object literals incorrectly. If you are targeting newer versions of JS, set the appropriate language_in option. at line 389 character 1 in all.js

theme : 'default', // The theme of the slider (default, theme1, theme2, t...

Where is the fault and what needs to be changed to fix the error?

$(window).load(function(){
jQuery('#slider1').autoSlider({
    theme               : 'default',    // The theme of the slider (default, theme1, theme2, theme3)
    width               : '960',    // The width of the slider, 100% for auto full width, set to 0 it will take the width of the largest image
    autoHidePlayBtn     : true,     //
Foi útil?

Solução

The fault (for fear of simply rewording what the Closure Compiler error says) is that IE8 and below cannot parse object literals and array literals which have a trailing comma.

var obj = {
    a: 1,
    b: 2, // trailing comma is bad!
};

... vs...

var obj = {
    a: 1,
    b: 2 // no trailing comma!
};

The fix is to remove the trailing comma.

Outras dicas

You have three options to get rid of this warning:

  1. Remove the trailing comma
  2. Change the compilation mode (using language_in) to later compilation mode such as ECMASCRTIPT6 or ECMASCRIPT6_STRICT (The trailing comma was standardized in EcmaScript 5).
  3. Change the compiler's warning level for the "es3" diagnostic group to "OFF".
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top