Experiment stuck on initialising - Pavlovia

URL of experiment: https://gitlab.pavlovia.org/cmfo/pvt-psychomotor-vigilance-task

Alert 4210:JavaScript Syntax Error in ‘Begin JS Experiment’ tab. See ‘Line 1: Unexpected token’ in the ‘Begin JS Experiment’ tab.
For further info see https://psychopy.org/alerts/4210.html
5119.4216 ERROR Line 91: Unexpected token in PVT-legacy-browsers.js

Description of the problem: The experiment does not run online, it remains indefinitely in the page that says “initialising experiment”. It works normally offline so it must be some problem with the conversion to JS which I was expecting since this one has a bit more of code.

I know I should not have used the “trials.thisN” as advised in previous posts but if I don’t and use “trials.thisTrialN”, it does not do what I need it to do.

Could you please point its faults so I can correct them? Thank you!

Also, do you know if the mouse is more precise than the keyboard?

@jonathan.kominsky Could this be a problem with the measures? It’s the only thing I can spot on the JS script.

It looks like there are import statements in the begin experiment code block, for the ISI trial type. Those are probably the source of the problem.

Yes, it is importing the random and time libraries, are they not available in Java? How does one go about it?

They are not, no import statements work in javascript right now. You’ll have to remove all of the import statements in all of the “Begin experiment” code components.

It depends what you’re trying to do with them, mostly. For shuffle, you have to create your own shuffle function. You can find a simple one that you can copy into a code component here: Reference error: shuffle is not defined

For any other sort of randomness, you can just use Math.random, which is built in to javascript.

For time, I’m not sure what you’re trying to do with it, but there are various util.Clock functions that should work.


I was getting the stuck with no error message to start with too – again because I was importing random. I’m putting together a crib sheet. Please comment on it if you have anything you’d like me to add.

Best wishes,



thank you for doing this! I will make additions once I know if my code is working, right now the experiment does not start so I have no clue.

My experiment is not running online too. On Psychopy it runs properly, but on Pavlovia is gets stucked on “Initiating the experiment”. What could I do to fix this?
Thank you