# Using jsPsych 7.1.2 from the tutorial can't be loaded

**URL:** <https://discourse.psychopy.org/t/using-jspsych-7-1-2-from-the-tutorial-cant-be-loaded/41360>\
**Category:** jsPsych\
**Created:** [September 11, 2024, 6:06am UTC](https://discourse.psychopy.org/t/using-jspsych-7-1-2-from-the-tutorial-cant-be-loaded/41360 "2024-09-11T06:06:01Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![JAQuent](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/jaquent/32/37887_2.png) [@JAQuent](https://discourse.psychopy.org/u/JAQuent)\
**Post date:** [September 11, 2024, 6:06am UTC](https://discourse.psychopy.org/t/using-jspsych-7-1-2-from-the-tutorial-cant-be-loaded/41360/1 "2024-09-11T06:06:01Z")

</div>

I am trying out the tutorial how to use `jsPsych` on pavlovia (see [Pavlovia](https://pavlovia.org/docs/experiments/create-jsPsych)). However, I am not able to load the plugins suggested by that page.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/b/b/bbed6fb7fa15185f593b658be8594c8873b15b40.png)

This links also returns a 404 error:  
[https://run.pavlovia.org/jaquent/jspsych\_test/lib/vendors/jspsych-7.3.1/plugins/jspsych-html-keyboard-response.js](https://run.pavlovia.org/jaquent/jspsych_test/lib/vendors/jspsych-7.3.1/plugins/jspsych-html-keyboard-response.js)

While a much older version can be loaded:  
[https://run.pavlovia.org/jaquent/jspsych\_test/lib/vendors/jspsych-6.0.0/plugins/jspsych-html-keyboard-response.js](https://run.pavlovia.org/jaquent/jspsych_test/lib/vendors/jspsych-6.0.0/plugins/jspsych-html-keyboard-response.js)

Could someone advise me which is the latest version of `jsPsych` that I can use how do I access that.

# The code

```auto
<!DOCTYPE html>
<html>
  <head>
    <title>My experiment</title>
    <script type="text/javascript" src="lib/vendors/jspsych-7.1.2/jspsych.js"></script>
    <link rel="stylesheet" type="text/css" href="lib/vendors/jspsych-7.3.4/css/jspsych.css"/>
    <script type="text/javascript" src="lib/vendors/jspsych-7.1.2/plugins/jspsych-html-keyboard-response.js"></script>
    <script type="text/javascript" src="lib/vendors/jspsych-7.1.2/plugins/jspsych-image-keyboard-response.js"></script>
    <script type="text/javascript" src="lib/vendors/jspsych-7.1.2/plugin-preload.js"></script>
    <script type="text/javascript" src="lib/jspsych-7-pavlovia-2022.1.1.js"></script>
  </head>
  <body></body>
  <script>

    /* initialize jsPsych */
    var jsPsych = initJsPsych({
      override_safe_mode: false,
      on_finish: function() {
        jsPsych.data.displayData();
      }
    });

    /* create timeline */
    var timeline = [];

    /* init connection with pavlovia.org */
	var pavlovia_init = {
		type: "pavlovia",
		command: "init"
	};
	timeline.push(pavlovia_init);

    /* preload images */
    var preload = {
      type: jsPsychPreload,
      images: ['img/blue.png', 'img/orange.png']
    };
    timeline.push(preload);

    /* define welcome message trial */
    var welcome = {
      type: jsPsychHtmlKeyboardResponse,
      stimulus: "Welcome to the experiment. Press any key to begin."
    };
    timeline.push(welcome);

    /* define instructions trial */
    var instructions = {
      type: jsPsychHtmlKeyboardResponse,
      stimulus: `
        <p>In this experiment, a circle will appear in the center 
        of the screen.</p><p>If the circle is <strong>blue</strong>, 
        press the letter F on the keyboard as fast as you can.</p>
        <p>If the circle is <strong>orange</strong>, press the letter J 
        as fast as you can.</p>
        <div style='width: 700px;'>
        <div style='float: left;'><img src='img/blue.png'></img>
        <p class='small'><strong>Press the F key</strong></p></div>
        <div style='float: right;'><img src='img/orange.png'></img>
        <p class='small'><strong>Press the J key</strong></p></div>
        </div>
        <p>Press any key to begin.</p>
      `,
      post_trial_gap: 2000
    };
    timeline.push(instructions);

    /* define trial stimuli array for timeline variables */
    var test_stimuli = [
      { stimulus: "img/blue.png", correct_response: 'f'},
      { stimulus: "img/orange.png", correct_response: 'j'}
    ];

    /* define fixation and test trials */
    var fixation = {
      type: jsPsychHtmlKeyboardResponse,
      stimulus: '<div style="font-size:60px;">+</div>',
      choices: "NO_KEYS",
      trial_duration: function(){
        return jsPsych.randomization.sampleWithoutReplacement([250, 500, 750, 1000, 1250, 1500, 1750, 2000], 1)[0];
      },
      data: {
        task: 'fixation'
      }
    };

    var test = {
      type: jsPsychImageKeyboardResponse,
      stimulus: jsPsych.timelineVariable('stimulus'),
      choices: ['f', 'j'],
      data: {
        task: 'response',
        correct_response: jsPsych.timelineVariable('correct_response')
      },
      on_finish: function(data){
        data.correct = jsPsych.pluginAPI.compareKeys(data.response, data.correct_response);
      }
    };

    /* define test procedure */
    var test_procedure = {
      timeline: [fixation, test],
      timeline_variables: test_stimuli,
      repetitions: 5,
      randomize_order: true
    };
    timeline.push(test_procedure);

    /* define debrief */
    var debrief_block = {
      type: jsPsychHtmlKeyboardResponse,
      stimulus: function() {

        var trials = jsPsych.data.get().filter({task: 'response'});
        var correct_trials = trials.filter({correct: true});
        var accuracy = Math.round(correct_trials.count() / trials.count() * 100);
        var rt = Math.round(correct_trials.select('rt').mean());

        return `<p>You responded correctly on ${accuracy}% of the trials.</p>
          <p>Your average response time was ${rt}ms.</p>
          <p>Press any key to complete the experiment. Thank you!</p>`;

      }
    };
    timeline.push(debrief_block);

    /* finish connection with pavlovia.org */
    var pavlovia_finish = {
        type: "pavlovia",
        command: "finish"
    };
    timeline.push(pavlovia_finish);

    /* start the experiment */
    jsPsych.run(timeline);

  </script>
</html>

```

---

<div class="post-metadata">

**Author:** ![JAQuent](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/jaquent/32/37887_2.png) [@JAQuent](https://discourse.psychopy.org/u/JAQuent)\
**Post date:** [September 12, 2024, 6:36am UTC](https://discourse.psychopy.org/t/using-jspsych-7-1-2-from-the-tutorial-cant-be-loaded/41360/2 "2024-09-12T06:36:53Z")

</div>

The code on the website is wrong or outdated. It works when I use `https://run.pavlovia.org/jaquent/jspsych7_test/lib/vendors/jspsych-7.1.2/plugin-html-keyboard-response.js`. The code on the website expects a directory called `plugins` and wants plugins to start with `jspsych` (`https://run.pavlovia.org/jaquent/jspsych_test/lib/vendors/jspsych-7.1.2/plugins/jspsych-html-keyboard-response.js`).

Does anyone know who I might contact to update the page [Pavlovia](https://pavlovia.org/docs/experiments/create-jsPsych)?

Edit: I got this from this working `jsPsych` example: [Alain Pitiot / jsPsych7\_simple\_reaction\_time · GitLab](https://gitlab.pavlovia.org/apitiot/jspsych7_simple_reaction_time)

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [January 27, 2025, 10:57am UTC](https://discourse.psychopy.org/t/using-jspsych-7-1-2-from-the-tutorial-cant-be-loaded/41360/3 "2025-01-27T10:57:23Z")

</div>

I’ve just remembered that I can update the docs on Pavlovia. Here’s the current markdown file. Please let me know any suggested changes.

[docs\_experiments\_create-jspsych.md](https://discourse.psychopy.org/uploads/short-url/t3iG483apPGB8cJBzVXTxXTOjoL.md) (8.4 KB)

---

<div class="post-metadata">

**Author:** ![JAQuent](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/jaquent/32/37887_2.png) [@JAQuent](https://discourse.psychopy.org/u/JAQuent)\
**Post date:** [February 25, 2025, 6:35am UTC](https://discourse.psychopy.org/t/using-jspsych-7-1-2-from-the-tutorial-cant-be-loaded/41360/4 "2025-02-25T06:35:39Z")

</div>

This looks good to me (sorry for late response).

---

<div class="post-metadata">

**Author:** ![Christophe\_Bossens](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/christophe_bossens/32/35415_2.png) [@Christophe\_Bossens](https://discourse.psychopy.org/u/Christophe_Bossens)\
**Post date:** [March 13, 2025, 10:26am UTC](https://discourse.psychopy.org/t/using-jspsych-7-1-2-from-the-tutorial-cant-be-loaded/41360/5 "2025-03-13T10:26:15Z")

</div>

Hi Wakecarter,

Is it still possible to update the docs? I noticed a few inconsistencies:

- jsPsych Pavlovia plugin link is not pointing to the latest version
- jsPsych does not accept strings for the type parameter
- The pavlovia finish function brackets are wrapped in quotes.

I have just uploaded my own jsPsych experiment on Pavlovia, so if you want I can make the necessary changes that made it possible for me to work.

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [March 13, 2025, 12:34pm UTC](https://discourse.psychopy.org/t/using-jspsych-7-1-2-from-the-tutorial-cant-be-loaded/41360/6 "2025-03-13T12:34:56Z")

</div>

Hi Christophe,

Please could you send upload a proposed updated version of the .md file here [Using jsPsych 7.1.2 from the tutorial can't be loaded - #3 by wakecarter](https://discourse.psychopy.org/t/using-jspsych-7-1-2-from-the-tutorial-cant-be-loaded/41360/3) or post the specific changes you are suggesting?

---

<div class="post-metadata">

**Author:** ![Christophe\_Bossens](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/christophe_bossens/32/35415_2.png) [@Christophe\_Bossens](https://discourse.psychopy.org/u/Christophe_Bossens)\
**Post date:** [March 14, 2025, 10:32am UTC](https://discourse.psychopy.org/t/using-jspsych-7-1-2-from-the-tutorial-cant-be-loaded/41360/7 "2025-03-14T10:32:47Z")

</div>

Will work on them and send them next week 😉

---

<div class="post-metadata">

**Author:** ![Christophe\_Bossens](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/christophe_bossens/32/35415_2.png) [@Christophe\_Bossens](https://discourse.psychopy.org/u/Christophe_Bossens)\
**Post date:** [March 20, 2025, 1:53pm UTC](https://discourse.psychopy.org/t/using-jspsych-7-1-2-from-the-tutorial-cant-be-loaded/41360/8 "2025-03-20T13:53:41Z")

</div>

Made the following changes:

- Referred to the latest CDN version of jsPsych (v8)
- Remove the reference to jQuery, which I did not need to include in order to get things working in this example
- Used the most recent convention to refer to jsPsych plugi types (jsPsychPavlovia instead of “jsPsychPavlovia”)
- Removed some unnecessary quotes in some of the example codes

Do you think there should be some additional info regarding different versions of jsPsych?  
[docs\_experiments\_create-jspsych.md](https://discourse.psychopy.org/uploads/short-url/lzFz2w0gh17C153BMyyuT7QJ3Cy.md) (7.9 KB)

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [March 20, 2025, 3:32pm UTC](https://discourse.psychopy.org/t/using-jspsych-7-1-2-from-the-tutorial-cant-be-loaded/41360/9 "2025-03-20T15:32:53Z")

</div>

Thanks. I’ve updated [Pavlovia](https://pavlovia.org/docs/experiments/create-jsPsych)

The only changes I made was changing some quotes that got mangled.

[docs\_experiments\_create-jspsych (2).md](https://discourse.psychopy.org/uploads/short-url/q1nJshDoTzb3viIjd48O2owZewy.md) (7.9 KB)

Additional info on different versions is probably a good idea.

---

<div class="post-metadata">

**Author:** ![Broinik](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/broinik/32/44997_2.png) [@Broinik](https://discourse.psychopy.org/u/Broinik)\
**Post date:** [April 19, 2025, 7:32am UTC](https://discourse.psychopy.org/t/using-jspsych-7-1-2-from-the-tutorial-cant-be-loaded/41360/10 "2025-04-19T07:32:27Z")

</div>

Hello!

I have noticed that the Pavlovia documentation site is still outdated. The link in the box is fine, but I tried downloading the link in the description, which sent me to the 2020 version. I finally found the 2022 version on GitHub…

 ![image](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/8/4/84686cd40262a39053adaad0bf4c7b93468bc016.png)  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/c/7/c7264fcee0daaf21e9464e2c2ba73d8b924b62e9.png)
