"SyntaxError: expected expression, got '<'"

Hello,

I’ve recently unearthed an old Unity project from 2016 (made with 5.3.4f1, and incompatible with the latest versions…) and decided to re-export it in WebGL and put it on my website.
It worked well in localhost. But when deployed on my website, this error was raised by UnityLoader.js :

Some old threads mentioned it was due to decompressing errors, so I followed the manual : Unity - Manual: Server configuration code samples
and since the three compressed files in the /Release/ folder are .memgz, .jsgz ans .datagz, I added this to my nginx.conf :

  location ~ .+\.datagz$ {
    gzip off;
    add_header Content-Encoding gzip;
    default_type application/gzip;
  }

  location ~ .+\.jsgz$ {
    gzip off;
    add_header Content-Encoding gzip;
    default_type application/javascript;
  }

  location ~ .+\.memgz$ {
    gzip off;
    add_header Content-Encoding gzip;
    default_type application/octet-stream;
  }

But it still doesn’t work :frowning: What’s even more strange is that my files seem to be correctly decompressed…

What should I do ?

are you sure your files end in datagz, jsgz and memgz? your html file says not.

They do, in both my local and remote repository. If you’re talking about pic related, these are the decompressed files.

I went to your website

        <script type='text/javascript'>
        var Module = {
            TOTAL_MEMORY: 268435456,
            errorhandler: null,            // arguments: err, url, line. This function must return 'true' if the error is handled, otherwise 'false'
            compatibilitycheck: null,
            dataUrl: "la-boule-clement-web/Release/WebGL_4.data",
            codeUrl: "la-boule-clement-web/Release/WebGL_4.js",
            memUrl: "la-boule-clement-web/Release/WebGL_4.mem",
        };
        </script>
        <script src="la-boule-clement-web/Release/UnityLoader.js"></script>

this doesnt show getting gz files.

whereas mine, is br but

     var buildUrl = "Build";
      var loaderUrl = buildUrl + "/Build.loader.js";
      document.getElementById('test').innerHTML = loaderUrl;
      var config = {
        arguments: [],
        dataUrl: buildUrl + "/Build.data.br",
        frameworkUrl: buildUrl + "/Build.framework.js.br",
        codeUrl: buildUrl + "/Build.wasm.br",
        streamingAssetsUrl: "StreamingAssets"
      };

does include the br, so this to me says its looking for different file names, hence wondering…

You’re right for noticing it, but perhaps the syntax is just different in your later version.
I had copypasted these lines from the index.html exported by Unity, so I guess that’s how it’s supposed to be written. In fact changing them to “.datagz” / “.memgz” / “.jsgz” makes it not work even in localhost…

9729772--1391224--upload_2024-3-27_5-26-58.png

(edit: typo)

no im wondering more if the config file needs adjusting…

I finally fixed it, by exporting it a later version (2020.1.8f1), old enough so the project could still be opened, but recent enough so it has the “Enable decompression fallback” option. It can be checked in WebGL Player Settings > Publishing Settings.
Now it works ! :smile: