4.5 Article

Precise display time measurement in JavaScript for web-based experiments

Journal

BEHAVIOR RESEARCH METHODS
Volume 55, Issue 3, Pages 1079-1093

Publisher

SPRINGER
DOI: 10.3758/s13428-022-01835-2

Keywords

Computer; Display; Timing; Measurement; JavaScript; Precision; Online research

Ask authors/readers for more resources

Conducting research online is a popular option for behavioral scientists, but the timing of display changes on web-browsers can be improved. This study found that using a recursive requestAnimationFrame (RAF) loop significantly improved precision compared to a single RAF call. Additionally, visibility or opacity changes were recommended for image stimuli. The study provides easy-to-use code for implementing this timing method.
Conducting research via the Internet is a formidable and ever-increasingly popular option for behavioral scientists. However, it is widely acknowledged that web-browsers are not optimized for research: In particular, the timing of display changes (e.g., a stimulus appearing on the screen), still leaves room for improvement. So far, the typically recommended best (or least bad) timing method has been a single requestAnimationFrame (RAF) JavaScript function call within which one would give the display command and obtain the time of that display change. In our Study 1, we assessed two alternatives: Calling the RAF twice consecutively, or calling the RAF during a continually ongoing independent loop of recursive RAF calls. While the former has shown little or no improvement as compared to single RAF calls, with the latter we significantly and substantially improved overall precision, and achieved practically faultless precision in most practical cases. Our two basic methods for effecting display changes, plain text change and canvas color filling, proved equally efficient. In Study 2, we reassessed the RAF loop timing method with image elements in combination with three different display methods: We found that the precision remained high when using either visibility or opacity changes - while drawing on a canvas element consistently led to comparatively lower precision. We recommend the RAF loop display timing method for improved precision in future studies, and visibility or opacity changes when using image stimuli. We publicly share the easy-to-use code for this method, exactly as employed in our studies.

Authors

I am an author on this paper
Click your name to claim this paper and add it to your profile.

Reviews

Primary Rating

4.5
Not enough ratings

Secondary Ratings

Novelty
-
Significance
-
Scientific rigor
-
Rate this paper

Recommended

No Data Available
No Data Available