| Reference | Downloads | Github

Stuck on experiment initialising

URL of experiment:

Description of the problem:

Everything is working offline i.e. on the computer but my study is stuck on initialising when I try to pilot it in a web browser. I only have a couple of user entered coding parts; one which randomises the conditions at the start of the expt (works offline) and the other prints a message at the end of the expt based on participant input.

I also got my friend to have a look at my auto-generated java script and he changed it slightly, but it still has the same issue (stuck on initialising).

I went back to the previous version of Python code (found from a post on this forum somewhere) with the auto-generated java script.

I’ve searched the posts with the same problem (seems to be common) but haven’t found a solution yet. I tried in both Firefox and Google Chrome.

I haven’t tried a version without the code.

My experiment has a rating scale component. I seem to remember that being an issue for online studies? Not sure if it could be that?

I’m not sure how to share my code here?

Hope someone can help.



Hi There,

You have an import * as random from 'random' statement on the javascript side of your code. This is valid python (so it works locally) but invalid Javascript (so it break online) please see the crib sheet for guidence


Hi Becca,

Thanks for your reply. Initially I thought that that was the issue so managed to get some help from a friend and used the following code in place of it (I also changed the psychopy code element to JS and then recompiled the JS):

function getRandomInt(max) {
return Math.floor(Math.random() * max);
switch (getRandomInt(3)) {
case 0:
condition = “A”;
case 1:
condition = “B”;
case 2:
condition = “C”;
msg = expInfo[“participant”];

It works as intended offline but it still didn’t initiate in the browser. I wondered if it might be an additional problem or something else I have overlooked or am missing.


Actually, I just tried it again with the code above - it now initialises, but I got the following error:

Unfortunately we encountered the following error:

  • ReferenceError: assignment to undeclared variable condition

Try to run the experiment again. If the error persists, contact the experiment designer.