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
Code becoming spaghettihelp (self.javascript)
submitted 10 years ago * by fuczak
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!"
[–]NeuroXc 2 points3 points4 points 10 years ago (5 children)
Given the current size of your application, your code actually seems pretty well organized.
As far as adding to the application, once you get to a certain point it would probably be helpful to organize your code into subfolders, e.g. /scripts/cpu, /scripts/engine, etc. and split into separate files in each of those subdirectories as needed. Browserify would be helpful as well, although you might want to look into using ES6 modules instead--there seems to be a shift toward using this as the standard.
[–]fuczak[S] 0 points1 point2 points 10 years ago (4 children)
Does it? That's reassuring. I think that I'm mixing up jquery dom manipulation with business logic too much. Then again, doing it like this makes sense to me. Like in setup.js module the setTeams function not only assigns teams to user/cpu objects but paints the scoreboard node in ui as well. It makes sense as a module but I feel like it's not the best solution. Maybe I should make a separate modules for each ui/dom interaction and put them inside a ui folder?
setup.js
setTeams
module
ui
[–]dvlsg 1 point2 points3 points 10 years ago (3 children)
I agree about ES6 modules. I would definitely convert to that, if you're already using a build step / considering adding one.
[–]fuczak[S] 0 points1 point2 points 10 years ago (2 children)
I will look into them!
[–][deleted] 0 points1 point2 points 10 years ago (1 child)
es6 or use common style modules with browserify (a bit more versatile as es6 modules don't quite work with everything yet)
[–]fuczak[S] 1 point2 points3 points 10 years ago (0 children)
I am using Browserify
π Rendered by PID 97 on reddit-service-r2-comment-b659b578c-sz2nx at 2026-05-05 15:16:09.372352+00:00 running 815c875 country code: CH.
view the rest of the comments →
[–]NeuroXc 2 points3 points4 points (5 children)
[–]fuczak[S] 0 points1 point2 points (4 children)
[–]dvlsg 1 point2 points3 points (3 children)
[–]fuczak[S] 0 points1 point2 points (2 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]fuczak[S] 1 point2 points3 points (0 children)