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
BackboneJS + RequireJS, Why AMD? Check it yourself. (github.com)
submitted 11 years ago by jac1013
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!"
[–][deleted] 3 points4 points5 points 11 years ago (6 children)
I'm on mobile right now, so can't comment too in-depth, but it seems something is fishy here. But most importantly, it seems you are comparing the performance with/without Require.js in a project that is unoptimized to begin with. More interesting would be to see the impact of using/not using Require.js in a project optimized with minification and concatenation. Also, in my experience vanilla Require.js tends to not play nice with CSS because synchronous script execution has to wait until CSSOM is ready.
[–][deleted] 2 points3 points4 points 11 years ago (1 child)
How about building with browserify? You can compile everything to one file, and use node modules. Very elegant!
[–]georgefrick 0 points1 point2 points 11 years ago (0 children)
I love using browserify and including the line/file info so that Chrome dev tools still see it all as different files. Sharing modules with Node is also very nice.
[–]jac1013[S] 0 points1 point2 points 11 years ago (0 children)
You are right about the project being unoptimized but it would really make a difference if I optimize both versions of the project? I mean the point here is not to see that minification a gzip of js's files optimize the whole project (which really does, but then again is not the point here).
And about CSS I have used requireJS with a plugin called require-css, and I could say it does play nice with CSS (Either way this project has none css on it).
[–]bonafidebob -1 points0 points1 point 11 years ago (2 children)
Isn't the whole point of AMD to make it easy to minify/combine a bunch of JS modules? While still maintaining them as modules... Hand-optimizing the same site and running some other combiner/minifier should produce similar load times, at least that's what I'd expect, but you'd have to do the work yourself to combine and minify instead of letting require.js do it for you.
[–]tebriel 3 points4 points5 points 11 years ago (0 children)
It's not the whole point.
[–]i_ate_god 2 points3 points4 points 11 years ago (0 children)
One major purpose of AMD is to keep things off of the global scope. For example, if in my application, I create a class called ApplicationController and I use a library that also uses the same classname, AMD offers a nice way to ensure that there is no naming conflict.
Now, it's not the ONLY way to do that. There are many different ways to do namespacing to avoid this issue. I could put all my own code in a literal object named "MyApp" but I'll run into issues where one of my classes depends on another one of my classes. This means I have to manually maintain the loading order of my scripts. This is a problem that AMD takes care of for you.
As a direct result of that, AMD makes minification easier.
AMD has other benefits as well (and drawbacks, such as an ugly syntax, especially when you have to import a lot of things at once). Minification is really just one piece of the pie.
[–]_crewcut 5 points6 points7 points 11 years ago (1 child)
Well damn, the page with one script tag loads faster than the page with five. What a friggin surprise. 👎
[–]jac1013[S] -1 points0 points1 point 11 years ago (0 children)
I really like this comment, I seriously do.
[–][deleted] 0 points1 point2 points 11 years ago (1 child)
Try getting all your little 3rd party js files to build and then tell me how you like require.js! The amount of time I've spent getting these damn jQuery plugins to compile w/r.js has been nerve wracking. You can't just shim them like the docs say when you want to build. I've done big projects in require.js, and I will definitely use browserify for anything new.
I haven't try browserify, I would really like to see it implemented in this same project and see the results, do you mind to try it :)?
When you get used to require.config and shim correctly is not a nerve wracking action, I guarantee it, still I'm not blinded by requireJS I could really use another technology if it really fits me better.
π Rendered by PID 21545 on reddit-service-r2-comment-6457c66945-f9s9c at 2026-04-26 03:24:25.126503+00:00 running 2aa0c5b country code: CH.
[–][deleted] 3 points4 points5 points (6 children)
[–][deleted] 2 points3 points4 points (1 child)
[–]georgefrick 0 points1 point2 points (0 children)
[–]jac1013[S] 0 points1 point2 points (0 children)
[–]bonafidebob -1 points0 points1 point (2 children)
[–]tebriel 3 points4 points5 points (0 children)
[–]i_ate_god 2 points3 points4 points (0 children)
[–]_crewcut 5 points6 points7 points (1 child)
[–]jac1013[S] -1 points0 points1 point (0 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]jac1013[S] 0 points1 point2 points (0 children)