# Parallel for loops in p5js

**URL:** <https://discourse.processing.org/t/parallel-for-loops-in-p5js/37997>\
**Category:** Coding Questions\
**Created:** [July 17, 2022, 4:19am UTC](https://discourse.processing.org/t/parallel-for-loops-in-p5js/37997 "2022-07-17T04:19:28Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mldvxcc](https://avatars.discourse-cdn.com/v4/letter/m/c67d28/32.png) [@mldvxcc](https://discourse.processing.org/u/mldvxcc)\
**Post date:** [July 17, 2022, 4:19am UTC](https://discourse.processing.org/t/parallel-for-loops-in-p5js/37997/1 "2022-07-17T04:19:28Z")

</div>

I was wondering if it is possible to run parallel for loops in JavaScript using the p5js library?

I am trying to speed up the following code and run multiple points in parallel given each is independent.

\<  
for (ix = 0; ix \< QSS; ix++) {  
for (iy = 0; iy \< QSS; iy++) {

```
    		st1 = 8 * Perlin((ix + xspeed * Tme) / 400 * xs * P2, (iy + yspeed * Tme) / 400 * xs * P2, Tme);
   			dst1 = Perlin((ix + xspeed * Tme) / 40 * xs * P2, (iy + yspeed * Tme) / 40 * xs * P2, Tme);
    		nss1 = Perlin((ix + xspeed * Tme) / 100 * xs * P2, (iy + yspeed * Tme) / 100 * xs * P2, st1 + dst1, Tme);
    		st2 = 8 * Perlin((ix + xspeed * Tme) / 800 * xs * P2, (iy + yspeed * Tme) / 800 * xs * P2, Tme);

		}
	}

```

> 

Perlin is a modified version of the p5js noise function. This seems embarrassingly parallel to me and would be easily possible in a different language, I am just wondering if there is any possible way in JavaScript. Many thanks in advance.
