Stimulus: A modest JavaScript framework for the HTML you already have

by milesfon 2/23/18, 3:05 AMwith 62 comments
by zdragnaron 2/23/18, 7:41 AM

I don't mean to knock the effort they've put in here, but this looks like all of the hand-rolled "frameworks" I saw my friends in the agency / consulting space made when they said angular 1 was "too heavy"... right down to the 'data-controller' attribute binding that everyone seemed to independently come up with.

Is there anything actually novel here? These types of things always seemed to run into composition issues (controllers inside of controllers) in terms of communication and what not. The net result was invariably far less appealing than, say, angular 1 or vue or non-SPA React.

by zaarnon 2/23/18, 8:47 AM

With 30KB in size, this framework might be something I can integrate into my websites to get a nice look-and-feel while preserving usability when script blockers are active.

Personally, when I work on projects I tend to develop a pure HTML+CSS solution first and then bolt on JS if needed, so this kind of stuff might make me more comfortable with writing proper webapps since it's still just basically "bolt JS on HTML".

by scottharveycoon 2/23/18, 4:37 AM

Previous discussion: https://news.ycombinator.com/item?id=16052105

I've been using Stimulus + Turoblinks for my current side project and I love it. Nice and simple way to add a bit of interactivity to existing HTML on your page.

by pjmlpon 2/23/18, 6:17 AM

As a VanilaJS advocate, I love it.

The manual even describes how to use just a plain <script> inclusion, instead of the build tool of the day.

by keybitson 2/23/18, 10:20 AM

This has a lot of similarities to intercooler.js http://intercoolerjs.org/ which I really enjoy when I don't need a full SPA type experience.

Can anyone with experience of Stimulus suggest why I'd pick it over intercooler?

by chuckdrieson 2/23/18, 4:47 AM

I like it a lot, but I'm always afraid that I'll end up running into limitations of the framework if whatever I'm doing happens to grow in scope in a way I hadn't planned for. I tend to be bad at planning ahead for side projects, but who can blame me, they're side projects.

Anyway, just stopping by to say that Vue has struck a good balance for me. Peppering in {{template values}} in existing HTML works really well, and when things start to get more complex I can easily break my dom out into components.

by meganiblaon 2/23/18, 8:14 AM

This is good at first look. Because it seems to be straightforward and carefully design. I like the aesthetic and choice of using data attributes being part of the HTML standard as directives to apply the framework.

One criticism I have relates to The syntax for denoting action methods. Did you agonize over the choice of syntax uses hash and implication? E.g.

    click->hello#greet
All the same this careful choice shows the effort you put into the framework . I’m just not sure this particular choice is to my taste nor works with regard to being consistent with the rest of the syntactic choices you have made.

Interested to hear thoughts of others in a discussion about this.

by austincheneyon 2/23/18, 10:18 AM

> export default class extends Controller {

I know it is vanilla ES6, but at some point it starts looking more like Java than JavaScript. The boilerplate necessary to convey a simple instruction is directly proportional to the averaged speed of everything else (authorship, maintenance, execution, testing, frequency of reuse, and so forth).

by dawnerdon 2/23/18, 9:34 AM

We wrote a pretty similar (like similar enough its kinda creepy) library[1] a while back and it's really helped speed up our front end dev. I LOVE having params set in data attributes. Makes re-usable modules, like a modal[2] or autocomplete [3], way easier to implement.

[1] https://github.com/firstandthird/domodule [2] https://github.com/firstandthird/simple-domodal [3] https://github.com/firstandthird/complete

by pankajdohareyon 2/24/18, 4:03 AM

First of all this isnt just another JS framework, The Framework is designed to work better with Rails, it is crafty in terms of how the DSL is designed. DHH is definitely the master of Designing DSL's, look at Rails and Activerecord. This too is excellent DSL design. So no its not for JS People, JS has react and what not. This is mostly geared towards Rails people.

by tiuPapaon 2/23/18, 5:55 AM

What's the advantage or disadvantage of using this when compared to something that works with Web Components like Polymer or stencil?

by diaspon 2/23/18, 9:48 AM

Works great, using it in my new notes app: https://github.com/notein/notein

by machiawelicznyon 2/24/18, 9:33 AM

I doubt it's any better than vuejs or preact.

by dsegoon 2/23/18, 12:20 PM

Feels like backbone without the baggage.

by taherchhabraon 2/23/18, 10:23 AM

one more frontend library !

by jorisbraunson 2/23/18, 11:23 AM

Yet another js lib.. no thanks. There are plenty enough alternatives