mirror of
https://github.com/jspsych/jsPsych.git
synced 2025-05-10 19:20:55 +00:00
42 lines
1.4 KiB
Markdown
42 lines
1.4 KiB
Markdown
# 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()`.
|
|
|
|
```html
|
|
<head>
|
|
<script src="https://unpkg.com/jspsych@8.1.0"></script>
|
|
<script src="https://unpkg.com/@jspsych/extension-example@1.0.0"></script>
|
|
</head>
|
|
```
|
|
|
|
```js
|
|
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:
|
|
|
|
```js
|
|
var trial = {
|
|
extensions: [
|
|
{type: jsPsychExtensionExample, params: {...} }
|
|
]
|
|
}
|
|
```
|
|
|
|
## List of Extensions
|
|
|
|
Extension | Description
|
|
------ | -----------
|
|
[jspsych‑ext‑webgazer.js](../extensions/webgazer.md) | Enables eye tracking using the [WebGazer](https://webgazer.cs.brown.edu/) library.
|
|
|
|
## Writing an Extension
|
|
|
|
See our [developer's guide for extensions](../developers/extension-development.md) for information about how to create a new extension. |