# Pause / stop / \`noLoop()\` p5 sketch when not actively seen by the user (e.g. after scrolling out of window)

**URL:** <https://discourse.processing.org/t/pause-stop-noloop-p5-sketch-when-not-actively-seen-by-the-user-e-g-after-scrolling-out-of-window/32294>\
**Category:** Beginners\
**Created:** [September 17, 2021, 10:48am UTC](https://discourse.processing.org/t/pause-stop-noloop-p5-sketch-when-not-actively-seen-by-the-user-e-g-after-scrolling-out-of-window/32294 "2021-09-17T10:48:06Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [September 18, 2021, 3:51am UTC](https://discourse.processing.org/t/pause-stop-noloop-p5-sketch-when-not-actively-seen-by-the-user-e-g-after-scrolling-out-of-window/32294/2 "2021-09-18T03:51:18Z")

</div>

> [@Multiple sketches in instance mode](https://discourse.processing.org/t/multiple-sketches-in-instance-mode/11222/4):
>
> Indeed it is so. But we can try to mitigate some of it. If you have a sketch which just displays a static drawing you can call noLoop() to halt the sketch: [p5js.org/reference/#/p5/noLoop](http://p5js.org/reference/#/p5/noLoop) 'use strict'; function setup() { createCanvas(500, 400); noLoop(); } Or if you have a sketch which only needs to update the canvas after a user input such as moving the mouse, besides using noLoop() you also call redraw() within the user input event callback: [p5js.org/reference/#/p5/redraw](http://p5js.org/reference/#/p5/redraw)[p5js.org/…](http://p5js.org/reference/#/p5.Element/mouseMoved)

---

_[View the full topic](https://discourse.processing.org/t/pause-stop-noloop-p5-sketch-when-not-actively-seen-by-the-user-e-g-after-scrolling-out-of-window/32294)._
