Uncaught ReferenceError: PsychoJS is not defined

URL of experiment: https://run.pavlovia.org/mkbaron/821update/html/

Description of the problem:

Hi everyone,

The experiment works perfectly fine when using the application on my computer, however it will not work online.

One immediate problem is that the project is unable to sync any changes I make.
When I press sync (or force sync using ctrl F5 as a previous thread suggests) nothing happens. The computer appears to be thinking (which makes me think it is working) but there is no message which confirms and there are no updates made to my online experiment.

Regardless, I initially got the experiment to work online up until it would reach one particular slide then it would quit and say it couldn’t locate one audio file. The audio file was on my desktop in the same folder as the rest of my files but for some reason this one file did not on the repository so I uploaded it manually. However the program still claimed it could not locate the file. I figured maybe there was an issue with the particular file, so I tried out a different one. Again it would not sync so I manually replaced the updated html and program and now the program does not even start and is stuck on “initialising experiment”. When I right click to inspect, I can see an error message which reads “Uncaught ReferenceError: PsychoJS is not defined”. I’ve tried recreating the experiment from scratch without luck. Wondering if anyone has any ideas of how to troubleshoot? I’m stuck.

Hi @mimihi,

Thanks for reaching out. It appears that the PsychoJS library imports are missing from the top of ‘a_psychopy_experi_kitfleece.js’. Looking at the gitlab repo, I can see those references removed with commit a7b1aa51. Adding back those import statements should take care of the problem, here to help if not.

Thanks a million for your help! Never would have caught that myself.

So I went to commit and pressed revert hoping that would retrieve the lost information but I guess I made the wrong move as the message still reads ‘initializing experiment’.

I tried to recreate from scratch: https://run.pavlovia.org/mkbaron/8-24update
Same issue: ‘initializing experiment’.

Thanks in advance for your assistance :slight_smile:

Alright, no worries, let me take another look :slightly_smiling_face:

OK it seems like the whole script is empty now, do I understand correctly you were trying to roll back a git commit and this happened?

Ah! Ok no the second link is something I just tried to “start over”.

This original link is the result of the revert attempt: https://run.pavlovia.org/mkbaron/821update/html/


Alright, no problem, thanks for the updated link, it seems to be running OK for me locally. Do you need help with staging in pilot mode to avoid the credit warning or are you still facing issues with getting the script to work as expected? Are image / audio resources loading properly?

Oh you are right! it is now working! However I am now back to the original problem where it will not load audio. For now I am not sure about images yet as it will not let me to proceed to that stage. Any ideas on how to proceed forward? Thanks again.

Of course, happy to help! Do you see any errors in the console? If you are loading .wav audio, only a few browsers support that format, but if you are testing on Chrome it should work fine.

One tweak I had to make to get this running for me locally was rename the ‘ice’ reference to ‘ice.wav’ if that makes any sense. Please also check out our manual for more information on queuing up resources for downloading at the start of the experiment.


Hm, so that was the item that I changed earlier via the Builder but it would not sync.
How were you did you make this change from ice to ice.wav?

Oh! I figured out how to edit the code directly with that one change. The program works now.

Thank you!


Hello! I have an additional question on this wondering if I can ask. So it seems that for me, I am only able to run one experimental project at a time. For my study I had created 3 separate psychopy projects representing 2 experimental conditions and 1 control condition. My vision is to have one pavlovia project that could randomly assign a participant to one of the experimental groups. I am wondering if PsychoPy Pavlovia is capable of this and if you have any method you would recommend to accomplishing this? Thank you so much.

Hey @mimihi, that should be possible I believe, quoting @TParsons “…basically you put the different conditions in their own loops and set nReps of each to 0 so it gets skipped, then set one to be not skipped according to whatever criteria you like”. Is that more or less what you had in mind? :blush:

The following thread may also be helpful,

Thanks for this. Sorry for the very late reply. I’m a new grad student. This time has been very challenging.

Before I can test if this randomization code works, I am encountering a persistent problem with a resource “unknown” that is indeed present. It works fine on psychopy desktop but does not work on pavlovia online. Thanks

FYI this is the URL

Thanks again for the help :confused:

Update on this: I’ve started a new experiment from scratch to clean up & purchased credits. However now it is saying I am unable to run my experiment when I run it. I feel like this is the same problem I had encountered before. :confused: Any advice?

Hey @mimihi, no problem, let me take a look, thanks for flagging, s.

Hi @mimihi, it looks like Pavlovia was having problems locating the PsychoJS library. I forked your project and updated the main script to import the latest PsychoJS, version 2020.2 instead of 2020.1. Is it running as expected now? Please note, Safari is unable to play back .wav audio and so you might need to convert your files into the mp3 format to achieve maximum cross browser support, x