Media preloading when using a templating engine #753
-
First, I want to thank all the folks behind jsPsych for this amazing resource! I have what may be naive but are hopefully quick questions about automatic media preloading: I am using a templating engine (from Django) to fill in the stimulus URLs for standard plugins. They are not wrapped in extra HTML and should be done filling in as paths by the time the page DOM is ready. In this case, will those stimuli be preloaded automatically (I'm guessing yes)? If media were preloaded automatically, and I were to try to additionally include manual preloading code to jsPsych.init, would that be ignored or would that lead to re-loading? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I think the answer is that the stimuli should be preloaded automatically as you guessed. I'm not certain, but if the template engine is merely dropping in strings before the JS is run then I don't see why it wouldn't work. If you manually preload images through |
Beta Was this translation helpful? Give feedback.
I think the answer is that the stimuli should be preloaded automatically as you guessed. I'm not certain, but if the template engine is merely dropping in strings before the JS is run then I don't see why it wouldn't work.
If you manually preload images through
jsPsych.init()
and those images are redundant with ones that were detected automatically then jsPsych will only load the image once. Essentially it builds a list that merges the automatic preloads with the manual list and then runs the preload on the merged list.