Skip to main content

Function: isP5AsyncCapable()

isP5AsyncCapable(version): boolean

Defined in: utils/utils.ts:74

Checks if the detected p5.js version supports async operations (Promise-based APIs).

Parameters​

ParameterTypeDescription
versionstringThe p5.js version string

Returns​

boolean

True if the version supports async operations (2.0.0+), false otherwise

Example​

const version = detectP5Version(p5Instance);
const supportsAsync = isAsyncCapable(version);

if (supportsAsync) {
const font = await p.loadFont("font.ttf");
} else {
const font = p.loadFont("font.ttf", onLoadCallback);
}