3 min read

Resources for running online experiments with jsPsych

Brief introduction

jsPsych “is a JavaScript library for running behavioral experiments in a web browser. The library provides a flexible framework for building a wide range of laboratory-like experiments that can be run online.” jsPsych is equivalent to psychtoolbox or psychopy when we run experiments in the lab. In short, it is the software/platform that we use to build experiments running in a web browser.

Pavlovia “is a place for the wide community of researchers in the behavioural sciences to run, share, and explore experiments online.” It is the place where you can store/host the experiments built with jsPsych (and also other softwares). Once it is set up appropriately, a link for the experiment can be obtained and shared with others (potential participants). Prolific is the place where you can recruit participants for your online experiments. It shares the link from Pavlovia to potential participants with custom criteria.

Cognition is the place where you can run jsPsych experiments online for free (but is not that handy as Pavlovia + Prolific).

Resources for learning jsPsych

It is highly recommended to go through the jsPsych tutorials (“Hello World” and “Simple Reaction Time Task”) before trying to work on your own project unless you have experience using JavaScript.

Once you completed the tutorials, you may want to check the jsPsych documents (e.g., timeline, and plugins etc). Whenever you first use a plugin, documents are the best place to start from.

Some tips

  1. You may use console.log() to check the variable value (e.g., for debugging purpose) and it will print the value in DevTools (see below). In Chrome, you can open DevTools by pressing Command+Option+I (Mac) or Control+Shift+I (Windows, Linux).
  2. In DevTools, you may also check the values of some variable in DevTools by typing the variable names.
A screenshot of DevTools in Chrome:

Resources for Pavlovia

Alert: Pavlovia + Prolific is the expensive option.
Note extra steps are necessary to make an existing jsPsych experiment available to run from Pavlovia. Detailed information is available here.

Pavlovia essentially uses Gitlab to store/host the experiments. Some knowledge of git may be helpful for uploading your experiments. One of the learning resources for git is here. You may need to complete at least the first 7 sessions. Note that session 7 is for Github, but the main idea is the same for using Gitlab. Alternatively, you may skip session 7 and follow the instructions on Pavlovia website.

Some tips

  1. Format the data saved in Pavlovia:
    In addition to run on_finish: within jsPsych.init() (e.g., Line 94 in this demo), Pavlovia also runs extra commands to save the data into Gitlab (e.g., Line 103 in the Pavlovia plugin). Note these extra commands save data for all frames/trials and columns. In other words, no .filter() or .ignore() is applied. If you would like to filter some rows and ignore some columns in the data file, you may modified the code (Line 103 in the Pavlovia plugin) by yourself. One example of the modified code is at Line 103 of this file.

Resources for Prolific

Alert: Pavlovia + Prolific is the expensive option.
Using Prolific is relatively straightforward. You just need to create a new study and select the criteria you would to apply.

Resources for Cognition

Note: Cognition is the free option.
I have not really tried Cognition by myself. But it seems that you have to incorporate all your jsPsych code to one file. Anyway, I still want to say this is an awersome option!