Custom Code in Pavlovia

The most important difference in coding for an online experiment is that it needs to be in JavaScript. Whether that is through the translate function, coding only in JS (recommended), or coding in both Python and JS separately. JavaScript is the main programming language of web pages (alongside HTML and CSS). Python cannot run directly on web pages.

Even when referencing elements of your PsychoPy experiment in custom code, these elements may be referred to differently between Python and JS (see the crib sheet here).

It is best to do as much of your experiment as possible in the builder view of PsychoPy, as the developers have worked hard to make sure that all of the builder components compile well to JS for usage on Pavlovia. Any custom code above that intended for Pavlovia usage, like what is covered on this site, will be in JS.