This is an open repository of jsPsych experiment timelines. The goal of this repository is to provide a place for researchers to share their timelines with the community. Packages in this repository all implement a uniform structure that makes it easy to use them in your own experiments and combine them with other code.
This is an open repository of timelines for jsPsych. The goal of this repository is to provide a place for researchers to share their jsPsych timelines with the community. Packages in this repository all implement a uniform structure that makes it easy to use them in your own experiments and combine them with other code.
The jsPsych timelines that have been contributed by community members can be found in the /packages directory.
The /packages directory also contains two template sub-folders that can be used as a starting point for contributing a timeline (see the Guidelines for contributing new timelines section).
| Timeline | Contributor | Description |
|---|---|---|
| arrow-flanker | Josh de Leeuw | Arrow flanker task for jsPsych |
| bart | Caroline Griem | Balloon Analog Risk Task for jsPsych |
| columbia-card | A. Hunter Farhat | The Columbia Card Task measures risk preferences through choices in a card game. |
| false-memory | Cherrie Chang | False memory task for jsPsych |
| go-nogo | URSI 2025 Team | A complete Go/No-Go task implementation for jsPsych measuring response inhibition and sustained attention. Includes interactive practice, configurable parameters, and comprehensive data collection. |
| hearts-and-flowers | Cherrie Chang | Implementation of the Hearts and Flowers task, which tests executive function. |
| spatial-cueing | Cherrie Chang | A shareable timeline of the Posner spatial cueing task. |
| spatial-nback | A. Hunter Farhat | A deployable spatial grid n-back timeline for jsPsych. Supports custom grid sizes, n-back levels, feedback, and more. |
The modules in this repository can be loaded via a CDN or via NPM. The CDN is the easiest way to get started. For example, to load the arrow-flanker timeline from the CDN, you would add the following script tag to your HTML document:
<script src="https://unpkg.com/@jspsych-timelines/arrow-flanker"></script>
⚠️ You will also need to import the jsPsych library and css CDNs, in addition to the timeline CDN:
<head>
<script src="https://unpkg.com/jspsych"></script>
<script src="https://unpkg.com/@jspsych-timelines/arrow-flanker"></script>
<link rel="stylesheet" href="https://unpkg.com/jspsych/css/jspsych.css">
</head>This will load the timeline into the global namespace as jsPsychTimelineArrowFlankerTask. You can then use the timeline in your experiment like this:
const jsPsych = initJsPsych();
const timeline = jsPsychTimelineArrowFlanker.createTimeline(jsPsych, {options});
jsPsych.run([timeline]);In the above example, timeline is a jsPsych timeline object that can be added to other timelines or used as the main timeline. The options parameter is an object that contains jsPsych timeline properties (in this case, fixation_duration: 400) to configure jsPsych properties present in the imported timeline. The configurable options are described in the documentation for each timeline.
Notice that each timeline module exports a createTimeline() method. This method returns an object with a timeline property that can be inserted into a jsPsych timeline and can be run without the optional options parameter to keep default timeline property settings.
const timeline = jsPsychTimelineModule.createTimeline(jsPsych, {options})
jsPsych.run([timeline])Timeline modules may also export a timelineUnits objects and a utils object.
The timelineUnits object contains functions that create smaller units of a timeline than the main createTimeline() method. For example, if the main timeline contains two phases (e.g., memorization and test) then there could be timelineUnits.createTestTimeline() and timelineUnits.createMemorizationTimeline(). These functions could then be used for assembling the overall timeline in a different way than createTimeline() allows. There are no constraints on what kinds of timeline creation methods can be exported in timelineUnits, other than the requirement that all methods return an object that can be added to a jsPsych timeline. Some modules may export methods to create units as small as a single trial, while others export no methods at all.
The utils object contains miscellaneous functions that may be useful when using the module. For example, if a timeline requires creating a complex stimulus that can be procedurally generated there could be a utils.createStimulus() method that returns HTML. Or if there is a timeline that involves a particular scoring system like a questionnaire with validated indicies then there could be a utils.generateScore() method. There are no constraints on what methods can be exported as part of the utils object.
If you would like to contribute a new timeline to this repository, please follow these steps:
- Fork this repository
- Create a new branch for your timeline (e.g., 'new-timeline-arrow-flanker')
- Run
npm installin the root directory of the repository to install dependencies. - Run
npm run newand answer the prompts to create a new timeline template in thepackagesdirectory. - Edit the files in the new timeline directory to implement your timeline.
src/index.tsis the main file that will be loaded when the timeline is used.README.mdis the documentation for the timeline.examples/index.htmlis a basic jsPsych experiment template that you can modify to illustrate how your timeline works. - Run
npm run buildto build the timeline. This will create adistdirectory with the compiled timeline. - Verify that the example works by opening
examples/index.htmlin your browser. - Add a changeset by running
npm run changesetin the main directory of the repository. This will prompt you for a description of the changes you made. This will create a new changeset file in thechangesetsdirectory. - Open a pull request to merge your branch into the
mainbranch of this repository.
We welcome timelines of all kinds!
If your timeline requires a custom plugin, we'd recommend adding the plugin to jspsych-contrib before submitting the timeline here. This will make it easier for other researchers to use your plugin in their own experiments. Currently, this repository is aimed at timelines that use plugins that are published on npm. Make sure the plugin and your timeline are both compatible with jsPsych v7+ so that they can work with each other and with the latest jsPsych version.