Live data from Hacker News

JavaScript: The Right Way

jstherightway.org

91–100 of 136 posts

Re: JavaScript: The Right Way

#91
post #85

Earlier quoted context omitted.

I've not heard of Zepto. Out of curiosity, why use it over jQuery?

Probably the file size argument, last time I read one of these discussions jQuery was 3x bigger gzipped at ~30kb.

Ok, that makes sense, especially for mobile development.

I looked it up, and it seems to be missing quite a bit, including the .noConflict() option, which I seem to have to use quite a bit when working on others' code....

Re: JavaScript: The Right Way

#92

Having recently started getting into Javascript, I have to say it is the most confusing ecosystem ever. Learning the basics of the language is easy enough, but as soon as you start trying to create a non-trivial application, bam, you're hit with information overload - X framework, Y library. It's different from Python, Ruby et all because at least with them, there are good consistent popular choices that you can rely…

I think there are 2 things at play that prevent a rails-like monolithic framework for js at the moment:

1) Front-end applications tend to have wider variation in functionality requirements from the start (real-time, graphs, animations, forms, modals, pushstate). There isn't a "standard CRUD app" that people are building with front-end js, often js is just being used for a single effect or widget.

2) Performance tradeoffs are very tangible to end-users. For instance, in most cases, straight HTML is still lighter and snappier than an AngularJS app (until you click on something, then that's another tradeoff) but an app served by 2 rails servers will usually be indiscernible from one served by 1 sinatra server.

With rails, you can say that the performance penalties are worth productivity gains because those penalties are really only going to effect deployment costs, not the UX. With JS, every extra bit you add to your framework is going to effect UX.

For me, the biggest pain is still dependency management. Bower is great for pulling stuff in but then I have to blend it with requirejs or an AMD loader or hand-wire it into my html. Likewise, when I want to remove something I have to touch a bunch of files. I'd love to just be able to "bower install backbone" and get back to writing code but building such a feature would require bower to be able to understand my project's structure.

Re: JavaScript: The Right Way

#93
post #41

Earlier quoted context omitted.

Backbone may or may not be right for you. Fortunately it's small, and fairly easy to read. The annotated sources [1][2] for BackBone and Underscore are fairly accessible. Also, I would highly recommend adding an AMD loader like require.js to your "basics kit". Code organization gets very important very fast, and it helps to think modular-and-reusable from the beginning. [1] http://underscorejs.org/docs/underscore.htm…

Plenty of debate these days over whether to use an AMD-based loaders like require.js [1], or to bundle all your js into a single file with Browserify [2]. Worth someone new being aware of, but that debate can get rather complicated. [1]: http://requirejs.org/ [2]: http://browserify.org/

All of you are giving good advice but I just have to chuckle at how quickly you all proved OPs point.

Re: JavaScript: The Right Way

#94

Having recently started getting into Javascript, I have to say it is the most confusing ecosystem ever. Learning the basics of the language is easy enough, but as soon as you start trying to create a non-trivial application, bam, you're hit with information overload - X framework, Y library. It's different from Python, Ruby et all because at least with them, there are good consistent popular choices that you can rely…

I'm with ya... there are a LOT of choices. A couple of days ago I was looking for a dropdown menu library. A simple Google search quickly turned up about 300 options. But to make it worse... the other library I was using for drag and drop layout (Gridster) was somehow munging the attributes of elements such that a dropdown menu using either of the first two choices I picked (Bootstrap and some JQuery plugin) both failed to work inside the draggable widget. And figuring out how to make Gridster work using elements instead of and was a PITA.

But in the end, I now have a way to build a nice draggable widget that can contain a menu in the draghandle. Now, to embed a Google Gadget in that (the menu is for setting UserPrefs) and make the OpenSocial API work... Oh joy.

Re: JavaScript: The Right Way

#95
post #61

Earlier quoted context omitted.

And definitely replace jQuery with Zepto (which is more-or-less a drop-in replacement), if you have control of the client (non-IE) or especially are working in mobile.

I've not heard of Zepto. Out of curiosity, why use it over jQuery?

When using Phonegap (and mobile web in general), I've experienced a pretty major delay between page load and jQuery running. Zepto seems to run instantly. YMMV.

Re: JavaScript: The Right Way

#96
post #61

Earlier quoted context omitted.

And definitely replace jQuery with Zepto (which is more-or-less a drop-in replacement), if you have control of the client (non-IE) or especially are working in mobile.

I've not heard of Zepto. Out of curiosity, why use it over jQuery?

[deleted]

Re: JavaScript: The Right Way

#97

Earlier quoted context omitted.

Plenty of debate these days over whether to use an AMD-based loaders like require.js [1], or to bundle all your js into a single file with Browserify [2]. Worth someone new being aware of, but that debate can get rather complicated. [1]: http://requirejs.org/ [2]: http://browserify.org/

All of you are giving good advice but I just have to chuckle at how quickly you all proved OPs point.

Yeah this is one of the best examples of people proving a point by trying to disprove it I've ever seen.

"The ecosystem isn't (that) confusing, just use X Y and Z"

- "No, use X Y and A"

-- "Who uses Y? Use C"

Myth: confirmed!

Re: JavaScript: The Right Way

#98
post #41

Earlier quoted context omitted.

Backbone may or may not be right for you. Fortunately it's small, and fairly easy to read. The annotated sources [1][2] for BackBone and Underscore are fairly accessible. Also, I would highly recommend adding an AMD loader like require.js to your "basics kit". Code organization gets very important very fast, and it helps to think modular-and-reusable from the beginning. [1] http://underscorejs.org/docs/underscore.htm…

Plenty of debate these days over whether to use an AMD-based loaders like require.js [1], or to bundle all your js into a single file with Browserify [2]. Worth someone new being aware of, but that debate can get rather complicated. [1]: http://requirejs.org/ [2]: http://browserify.org/

Just a heads up, but require.js supports moving everything into a single file:

http://requirejs.org/docs/optimization.html

Your comment makes it seem like it doesn't.

Re: JavaScript: The Right Way

#99

Earlier quoted context omitted.

All of you are giving good advice but I just have to chuckle at how quickly you all proved OPs point.

Yeah this is one of the best examples of people proving a point by trying to disprove it I've ever seen. "The ecosystem isn't (that) confusing, just use X Y and Z" - "No, use X Y and A" -- "Who uses Y? Use C" Myth: confirmed!

hahaha this was hilarious even before I saw the 15 or so additional contradictory suggestions below this thread.
Post reply on HN