Skip to content

Extensions

Extensions are jsPsych modules that can interface with any plugin to extend the functionality of the plugin. A canonical example of an extension is eye tracking. An eye tracking extension allows a plugin to gather gaze data and add it to the plugin's data object.

Using an Extension

To use an extension in an experiment, you'll load the extension file via a <script> tag (just like adding a plugin) and then initialize the extension in the parameters of initJsPsych().

<head>
  <script src="https://unpkg.com/jspsych@7.3.4"></script>
  <script src="https://unpkg.com/@jspsych/extension-example@1.0.0"></script>
</head>
initJsPsych({
  extensions: [
    {type: jsPsychExtensionExample, params: {...} }
  ]
})

To enable an extension during a trial, add the extension to the extensions list for the trial. Some extensions may also support or require an object of parameters to configure the extension:

var trial = {
  extensions: [
    {type: jsPsychExtensionExample, params: {...} }
  ]
}

List of Extensions

Extension Description
jspsych‑ext‑webgazer.js Enables eye tracking using the WebGazer library.

Writing an Extension

See our developer's guide for extensions for information about how to create a new extension.