jsPsych is a powerful library for constructing behavioral experiments in Javascript. It is possible to embed jsPsych within psychTestR. This is useful when you want to take advantage of jsPsych’s timed stimulus presentation facilities.

psychTestR does not yet provide dedicated helper functions for embedding jsPsych, partly because of recent changes to jsPsych’s API. However, we give an example below of how this integration can be achieved. We intend to incorporate this functionality more explicitly into future releases of psychTestR.

If you have trouble getting the following to work, please contact Peter Harrison at pmc.harrison@gmail.com - we’d appreciate a chance to update this documentation.

jsPsych library file

This core part of the jsPsych installation can be found here: https://github.com/jspsych/jsPsych

jsPsych initialization file

This is the jspsych_init file of the jspsych function above.

This file should look something like this:

Depending on the version of jsPsych the definition of display_element needs to change slightly, according to the comments above.

jQuery

The jQuery library file can be downloaded from here: https://jquery.com/download/ Later versions of jsPsych may not need jQuery to be loaded.