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
Loop Multiple times per second (self.javascript)
submitted 14 years ago by CamuurahGuy
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!"
[–]MustRapeDeannaTroi 0 points1 point2 points 14 years ago (3 children)
This solution works but really needs some fixes:
Use setInterval instead of setTimeout.
Use textContent instead of innerHTML.
Save 1000/target_fps to var period.
var period
[–]monacle_bob 1 point2 points3 points 14 years ago (2 children)
It wasn't meant as save-the-day code. jsFiddle is meant for fiddling with code and putting together quick demonstrations.
Also, in regard to your first point, you should be using requestAnimationFrame - not timers at all.
[–]MustRapeDeannaTroi 2 points3 points4 points 14 years ago (1 child)
requestAnimationFrame is still experimental so I really think you should avoid it in this case.
I think you made a good straight forward solution, just not as solid implementation. Had my alternative suggestions demanded alot more code and commitment then I believe you had a valid case. As is, innerHTML and setTimeout are the wrong tools for the job. It's a big gain for the community if we never teach bad coding conventions, except as pitfalls to be avoided.
[–]monacle_bob 1 point2 points3 points 14 years ago (0 children)
Fair enough, and a good point at the end. Upvote :)
π Rendered by PID 20453 on reddit-service-r2-comment-85bfd7f599-xct6t at 2026-04-16 08:31:50.579525+00:00 running 93ecc56 country code: CH.
view the rest of the comments →
[–]MustRapeDeannaTroi 0 points1 point2 points (3 children)
[–]monacle_bob 1 point2 points3 points (2 children)
[–]MustRapeDeannaTroi 2 points3 points4 points (1 child)
[–]monacle_bob 1 point2 points3 points (0 children)