My experiment works locally, but online I get different errors such as initialising the experiment and unknown resource errors

Ahhh, that makes sense now! I think it’s not too hard to adapt my js code to these specifications. Essentially you just have to run it four times. Once for each chunk. You can use https://jsfiddle.net/ to test your js code. (you just have to add console.log(stims) to the code to get an output of what your stims array looks like)

Thank you for the recommendation with jsfiddle.net. That makes it a lot easier and I found a solution based on your code. In case anyone else should be interested it is:

// function for shuffling
function shuffle(array) {
  var copy = [], n = array.length, i;

  // While there remain elements to shuffle…
  while (n) {

    // Pick a remaining element…
    i = Math.floor(Math.random() * array.length);

    // If not already shuffled, move it to the new array.
    if (i in array) {
      copy.push(array[i]);
      delete array[i];
      n--;
    }
  }

  return copy;
}


// function for generating a sequence
function range(start, end) {
          return Array(end - start + 1).fill().map((_, idx) => start + idx)
      }
            
numimg = 192;
letter1 = new Array(numimg / 16).fill([".jpg", "_06_03.jpg", "_07_03.jpg", "_08_03.jpg"]).flat();
letter2 = new Array(numimg / 16).fill([".jpg", "_06_03.jpg", "_07_03.jpg", "_08_03.jpg"]).flat();
letter3 = new Array(numimg / 16).fill([".jpg", "_06_03.jpg", "_07_03.jpg", "_08_03.jpg"]).flat();
letter4 = new Array(numimg / 16).fill([".jpg", "_06_03.jpg", "_07_03.jpg", "_08_03.jpg"]).flat();

letter1 = shuffle(letter1);
letter2 = shuffle(letter2);
letter3 = shuffle(letter3);
letter4 = shuffle(letter4);

console.log(letter1)


// generate image array
imagearray  = range(1, numimg)
imagearray = shuffle(imagearray);

distortion = letter1.concat(letter2).concat(letter3).concat(letter4)

// merge both arrays element by element to get the final stim array
stims = [imagearray , distortion ].reduce((a, b) => a.map((v, i) => v + b[i]))

// shuffle
stims = shuffle(stims)

I really appreciate your input. I may have some future tweaks, but they will probably be relevant for a new topic.