r/javascript • • Jul 02 '17

help Want to build an SPA without using the framework (Angular, React, Vue). Please help to compose a stack

Hey folks,

I want to build a Single Page Application without using heavy frameworks, like Angular, React, Vue.

First of all, I would like to mention, that I want to make an SPA, not single page website, so routing is required. I will need contexts (for filtering and passing data) and so far Page.js seems like the best option: http://smalljs.org/client-side-routing/page/

Second of all, I am not opinionated about templating, as long as it has If, Elif, Repeats and such. Even LoDash/Underscore 's _.template() seems to work as for me.

For control flow I am thinking of async.js.

The last, but not the least, the data binding and states. I have bad experience with Redux and Flux since both involve a lot of template code copy-pasting, and to be honest, are confusing. I have much better experience with two-way data binding and MobX. I am also very keen for RxJS and Bacon.js, so if you know solutions working tightly with them, please note that fact.

Finally, as for the build system. I have experience with both Gulp and Webpack. With Webpack, I managed to setup it to work with ESLint, which helped a lot during development. Gulp, however is easier for understanding and seems to be much more lightweight (but again, I might be opinionated because I used webpack for Angular 2 and React bundling).

As for the front-end framework, it's best to use Bootstrap if any needed. It's easy to make a grid system and other components from zero, but sometimes rapid prototyping is needed.

jQuery is neither a problem.

Here are the requirements:

  • E2E tests

  • IE9+ support, so ES6 has to be transformed with Babel into ES5

  • HTML partials, since I plan to inline SVGs a lot.

2 Upvotes

38 comments sorted by

23

u/dbbk Jul 02 '17

Why would you want to do this? You'd be making your life really hard for no real reason.

7

u/placidified Jul 02 '17

Job security perhaps ?

/sarcasm

-12

u/ngDev Jul 02 '17

To know exactly how everything works and not to have downtime on researching and debugging. Similar to custom PC builds. You have a choice to choose components (not stuck on some lame capped CPU for example). And if something breaks, you do not need to guess what is placed where how and with which screw with OEM. Also, you can throw in any aftermarket makes of the parts. Take custom build PC and All-in-one. What's easier to setup - All-in-one definitely, plug and play. What is more petfomant for same buck - custom build definitely. At least in cooling terms. What's easier to maintain - custom build again. 2 Pros vs 1 Con :)

22

u/GitCookies Jul 02 '17

Custom PC build is same as React+React-Router+Redux.

What you want to do is same as making your own CPU, RAM, Motherboard and etc.

-4

u/ngDev Jul 02 '17

And how would you classify this then?

https://developer.mozilla.org/en-US/docs/Web/API

7

u/GitCookies Jul 02 '17

Basic/Medium level knowledge.

-1

u/ngDev Jul 02 '17

And React/Redux as Extreme level of knowledge?

4

u/GitCookies Jul 02 '17

React/Redux still requires low to medium knowledge. It's basic stuff.
Writing React from scratch however, takes some high-level knowledge, loads of testing, and etc.

12

u/dbbk Jul 02 '17

You're quite naive if you think forgoing a battle-tested framework with hundreds/thousands of contributors for something hand-rolled on your own is going to be more performant and easier to maintain in the future. Especially if you ever need to bring on more developers than just yourself.

7

u/Macaframa Jul 02 '17

ESPECIALLY IF HE DOESNT KNOW WHATS GOING ON BEHIND THE SCENES IN ANY OF THOSE FRAMEWORKS. Sounds like he wants to learn how to build a framework and get paid while doing it. Oh honey, you don't get both.

1

u/ngDev Jul 02 '17

Why would I want to build a framework?

To maintain the similar-to others opensource solution with zero users?

3

u/holocen Jul 02 '17

I think if you would have left it at you wanted to know how everything works under the hood, that would be understandable. The analogy you use really falls through though because putting a couple PC parts together is nothing like making your own framework.

2

u/ngDev Jul 02 '17

My goal is not to make my own framework.

My goal is to stack up libraries to have full control under the hood, and to have interchangeable parts.

1

u/[deleted] Jul 02 '17

React is merely a library that works well with other parts too. In fact, you mention you want to use page.js for router: I can recommend it, I use it too... with React.

1

u/ngDev Jul 02 '17

With React it is okay for me.

React without router, and Redux is okay for me.

TL;DR React as View is okay for me :)

2

u/doggobotlovesyou Jul 02 '17

:)

I am happy that you are happy. Spread the happiness around.

This doggo demands it.

1

u/spinlock Jul 02 '17

How many operating systems do you run on your custom pc? If you want to support one browser, it's an ok comparison. But, you want ie 9 support. Frameworks offload cross browser support as one if not the most important feature.

Also, you should keep working on Redux until you understand it. Two way data bindings are out of style for a very good reason. They complect your app in ways that are very hard to understand. Shared state is a godsend in comparison and the boilerplate is pretty trivial to manage with a generator.

0

u/ngDev Jul 02 '17 edited Jul 02 '17

Redux is okay for me if spending load of time was compensated. In my case, it is not. It's good for large applications.

Concerning the IE support, I have specified that in the original post. Usually, libraries specify their support range.

1

u/spinlock Jul 02 '17

It's true, you can save hours of configuring Redux with days of debugging 2 way bindings 🙃

0

u/ngDev Jul 02 '17

Debugging happens once in a while let's say.

3

u/drsco Jul 02 '17

Your comparison strikes me as a bit naive, but I like your enthusiasm and curiosity. The brutal downvotes here are uncalled for. I would heartily encourage you to take this on as long as you don't intend to unleash your first attempt into a production deployment environment.

Please check out the following libraries and see if they are to your liking - I think they align well with your stated goals.

https://github.com/Raynos/mercury

https://github.com/substack/hyperx

https://github.com/Raynos/main-loop

https://github.com/Matt-Esch/virtual-dom

If you poke through the associated GitHub pages, I think can find some other good libraries and slides from presentations. Happy coding!

2

u/lunfaii Jul 02 '17

Backbone is perfect! You can choose to use Marionette on top of it but I feel like Backbone, jQuery and Underscore/Lodash will be a fine combo for you.

1

u/ngDev Jul 03 '17

Yeah, I have checked it out recently and I like that it is tightly coupled with LoDash.

Also, the architecture looks good for me.

But I haven't checked the source code yet

6

u/[deleted] Jul 02 '17

I would suggest trying hyperapp or preact, both are really lightweight frameworks with great support. Unless you want to build your SPA just to learn how to do it. To be honest, if you plan on using this for production, the implementation built by a single person is not going to beat any framework built by a community (unless it's a really good one, like hyperapp).

2

u/leeoniya Jul 02 '17 edited Jul 02 '17

2

u/ngDev Jul 02 '17

I seem to like DomVM and ReDom.

However, I was thinking about Riverts (http://rivetsjs.com/docs/guide/) or something like that + jQuery in EventEmitter - Listener pattern in functional programming flavour for refactoring simplicity.

5

u/leeoniya Jul 02 '17 edited Jul 02 '17

judging by your original post, it seems you're quite capable of evaluating what works best for you, so good luck!

15

u/carrot_gg Jul 02 '17

How on earth is Vue a "heavy" framework? A full-featured Vue project with Vuex + vue-router weights 30KB gzipped.

1

u/subvertallchris Jul 02 '17

Having worked in a place where the person in charge suffered terribly from NIHS, this sounds like you are headed down a frustrating path.

1

u/ngDev Jul 02 '17

Using jQuery instead of Angular or React or {{ insert_shiny_new_framework_name }} and some library to do the routing is NIHS.

6

u/digdic Jul 02 '17

this is a really bad idea, there's no reason to not use a framework on a production SPA

2

u/ccb621 Jul 02 '17

Naming semantics aside, you want to build your own frontend framework. Rather than tell you this is a bad idea, I would encourage you to research existing libraries and frameworks. Focus on what they get "right" and what they get "wrong" (according to whatever metric you decide). Can you build something that meets all of your needs cheaper—in terms of time spent developing now and debugging later—than it would take to use an existing framework and work around the things it got "wrong"? If so, go forth and build your own. If not, pick something that exists and build atop that foundation.

If you just want to learn how it all works, this exercise applies, but you'll want to dig deeper into the source code to see how the existing solutions work.

1

u/[deleted] Jul 02 '17

lol

0

u/dragni Jul 02 '17

You should give Polymer a try, it's a lightweight library build on top of the webcomponent specifications. It has everything you need and relies heavily on the web platform as it is instead of custom framework code (https://www.polymer-project.org)

-1

u/ngDev Jul 02 '17

My colleague has had bad experience with it. Things get wild when more components are thrown in. Plus, polymer incorporates material design, meanwhile in my case, I get very specific design requirements :)

1

u/dragni Jul 02 '17

I think it depends on the way you build your component architecture. Polymer is used in production by some big companies for big projects (Google is using it for both Google Earth and the new YouTube for example). It just requires some more thought then a framework which often pushes you towards a specific architecture. Regarding the Material Design, that is indeed embedded in the paper elements created by the Polymer team. Polymer itself however has nothing to do with material design, there are loads of elements which are not using material design you could use (take a look at webcomponents.org)

1

u/ngDev Jul 02 '17

To be honest my post was not about going for exotics.

I wanted just to dich architecture-oriented frameworks, and try to build a stack from a couple of libraries. Going for polymer in my case is not going to be a good idea, since I am doing transition from well tested Angular, React, Vue to lesser-known framework, with less community support.