
Insanely fast server side rendering middleware for Express - YoussefKababe
https://github.com/YoussefKababe/serender
======
richmarr
This module essentially proxies requests on the fly using a headless browser
and returns the rendered HTML.

This is quite a sneaky solution to some types of problem (and the module
weighs in at an enviable 18 lines of code).

That said, I have a hard time how "insanely fast" is a reasonable claim.

~~~
YoussefKababe
"Insanely fast" was borrowed from the project that Serender is based on, which
is Zombie (an insanely fast headless browser used for testing client side
code). Now of course, the speed of rendering depends on how fast your client
side code is. If it has some ajax calls that fetch some really heavy data, the
rendering can take few more milliseconds, but it's still fast because there is
a very low network latency and your database is surely on the same network as
your application, if not on the same server! I'm claiming that it's "insanely
fast" because creating a new headless browser instance takes nearly no time at
all, so the speed totally depends on your client side code.

~~~
richmarr
Sure, makes sense. I guess it's the difference between 'fast' relative to
other rendering methods and 'fast' relative to the actual work that's being
done.

------
drinchev
Well If I write my code in a decent way, I wouldn't need to use that
middleware.

Another thing that pops up in my mind is scaling. What happens if I have 200
request to my front page for 1 second?

~~~
YoussefKababe
Yes, no one's forcing you to use that middleware of course! But saying that
you don't need to use it because you can write decent code is seriously not a
relevant reason. The idea behind this middleware is to provide a solution that
works regardless of what front-end framework you use. Sure you can do it with
decent code and handle fetching data and passing it to your templates
yourself, but your decent code will probably work for one single framework,
and maybe for just that single application you're working on, and it can get
messy! Can you imagine now how much work and time this middleware can save
you? Regarding your question about scaling, if your application can handle 200
requests per second, I think it will work just fine even when using this
middleware. Expect seeing some benchmarks soon! Also, next versions will
provide an option that lets you choose to render your pages only when the
request is coming from a search engine bot or a social network scrapper.

~~~
drinchev
Hey. Great reply. Kudos for that passion on your framework.

~~~
YoussefKababe
Thank you!

