| Reference | Downloads | Github

Pavlovia: trying to run additional .js script gives error

URL of experiment:

Description of the problem:

I am trying to incorporate Li et al.'s virtual chinrest ( into our experiment. I have tried to include it in the index.html file in the following way:

<script type='text/javascript' src='./virtual_chinrest.js'></script>

I’ve also tried using script type =“module”. In both cases, nothing happens when I Pilot the experiment via Pavlovia - it goes straight to the experiment (bg_1a.js).

When I try to run the virtual_chinrest.js script only (by commenting out bg_1a.js, the actual experiment), the screen is stuck on “Initializing the experiment”, and there is nothing in the console.

I have no experience with Javascript, so I would appreciate if someone can guide me through the process or point me to the right direction! Thank you!

The function in their .js file interacts with the elements defined in their .html file. So you would need to incorporate both .js and .html for it to work. Since it depends on the presentation of the slider, the .css file is probably needed as well for proper calibration.

Added to all this work is that psychojs has this scheduler function that adds loops and trials in order to run things sequentially. It takes over the page rendering with the start of the experiment and generates all html elements with the psychojs library. So I’m not sure simply putting those elements into your .html file would work. You probably need to rewrite the experiment .js file quite a bit and have a lot of custom functions to generate the interface for virtual chinrest.

If you really want to use their implementation, I strongly suggest keeping these two webpages separate to avoid this whole mess, especially since you said you don’t have much experience with javascript.

If you want to have everything in one place, recreating the same interface using psychopy/psychojs would be much easier.

Thanks for the reply and the suggestions!

@gavin-ng I’m looking to do exactly the same thing here! I also have no experience with Javascript, so I’m stuck at the same place. Would you be willing to share if you figure anything out with this?? (i.e. how to implement in psychopy/psychojs or how to incorporate after the fact)