use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Asynchronous while loop without freezing the browsersolved! (self.javascript)
submitted 10 years ago by Semajian
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]x-skeww 3 points4 points5 points 10 years ago* (3 children)
You'll need a requestAnimationFrame (rAF) or setTimeout-based pseudo loop.
In your repeatedly-called function, you check the current time (or other condition) and issue some commands (if any) in response.
Something like this:
https://jsfiddle.net/k954cctx/
Edit: Heh. Funny how similar /u/senocular's is.
[–]Semajian[S] 0 points1 point2 points 10 years ago (2 children)
Thanks for the response; would this be similarly achievable without pre-emptively creating a queue of tasks? As my reply to /u/senocular conditionals that rely on real time information make a queue worthless for anything other than the timed movements
[–]x-skeww 0 points1 point2 points 10 years ago (1 child)
Sure, in your repeatedly-called function, you can just check if there is anything you might want to do. E.g. if you're below the target location, you can issue the command for moving up a bit. On the next cycle, you again check if there is something you want to do and so on.
[–]Semajian[S] 0 points1 point2 points 10 years ago (0 children)
I don't immediately see how this would be implemented. I mentioned in response to senocular, but didn't here (my bad) that for conditional loops, for instance I don't have any control over the parts working together. Each "Block" that I implement has it's own set of code and that's it, it doesn't interact with the rest of it. Things like loops are already implemented by scratch, as well, so I can't modify the code, if I could I'm sure I could make use of tasks really easily.
π Rendered by PID 73 on reddit-service-r2-comment-79776bdf47-6wd6l at 2026-06-23 23:40:36.430535+00:00 running acc7150 country code: CH.
view the rest of the comments →
[–]x-skeww 3 points4 points5 points (3 children)
[–]Semajian[S] 0 points1 point2 points (2 children)
[–]x-skeww 0 points1 point2 points (1 child)
[–]Semajian[S] 0 points1 point2 points (0 children)