psychopy.org | Reference | Downloads | Github

Dealing with the NoModule version of the PsychoJS library

I just found out that the PsychoJS library have two versions, one for modern browsers (using modules) and one for legacy browsers (i.e. Internet Explorer). This is also the reason why PsychoPy generates two scripts, e.g. stroop.js and stroopNoModule.js.

I have been working exclusively on the stroop.js-like version of the library (the stroopNoModule.js-like script is similar to the other script, but lacks a few things I added manually). I was wondering what that would mean for a subject to use Internet Explorer. Would they still be able to actually take the experiment? I can test it myself since I am working on a Mac.

Yes, the NoModule version is for older browsers like IE and changes you make to the main script won’t be reflected there. As with Python scripts we strongly recommend that you insert your custom code into Code Components in Builder rather than hacking the script. It also means that if you do make further changes to your study you can do so in Builder without having to redo all the hacks.

Thanks for the tip, however some of the things I added in the code could not have been added through the Code Component, so I had to work on the script directly.

So the only solution to have the two script version same to one another is just to use the code component? Is there a way to fix this by hand?

Can you say why? Are they needed for something before the code components are available?

You can change both scripts every time you change one of them. It really is better to add Code Comps! :wink:

Among other things, I wanted to have a text input field in one of the routines and I felt like it was just easier to work on the actual script rather than figure out where each code chunk should go in the experiment (e.g., at the beginning/edn of the experiment/the routine, at each frame of the routine).

So I can just copy and paste the code from the other script? Is the code itself the same (and the difference is just “under the hood”)?

By the way, I just tested the experiment on both Microsoft Internet Explore (MIE) and Microsoft Edge (ME) and neither works. When using MIE, a nice error message says that PsychoJS does not support the browser. When using ME, the screen is stuck on the “initializing experiment…” message. (It would be nice to have the same error message for both browsers, just so that subjects using either know about it.)

This is just to let you know that the NoModule.js file is not working anyway, so it is not an issue right now (but it might be if/when MIE will be supported).

We are going to support IE again (hopefully soon). Edge should be working.

Adding a text entry field into a routine should absolutely be possible with Code Components. That’s absolutely the thing to do.

The differences between the files are mostly structural in terms of how importing libraries is carried out. The code for each piece is the same

When I tried the experiment, it got stuck on the ‘initializing experiment…’ message (while it seamlessly works on Chrome/Safari/Firefox).

Ok, I will start using the Builder then.

Cool, so I guess I could just copy and paste the code from the other version of the script and pay attention to the preamble of the script.

Thanks!

I am also having problems with the noModule scripts and the Microsoft Edge browser.

In Microsoft Edge it looks as if the Javascript isn’t loading at all?

In Chrome, if I try to run the nomodule version of the script, I get a ‘PsychoJS is not defined’ error - from looking at the code the noModule file looks exactly the same as the regular javascript code but is just missing the import statements (as expected) so errors when it tries to declare:

var psychoJS = new PsychoJS({
debug: true
});.

This also happens in Safari (see below) Should the missing modules be loaded some other way? :slight_smile:

Chrome

Safari