A recipe, boarding pass or presenter view should not dim. navigator.wakeLock.request('screen') returns a WakeLockSentinel; the browser releases it when the tab is hidden or the battery runs low, so request it again when the page becomes visible. The API became Baseline Newly available in March 2025.
let lock = null;
const keepAwake = async () => { lock = await navigator.wakeLock.request('screen'); };
cookButton.onclick = keepAwake;
document.addEventListener('visibilitychange', () => {
if (lock?.released && document.visibilityState === 'visible') keepAwake();
});Call lock.release() when the task ends. Wrap request() in try: it rejects in power-saving mode.