The Challenges and Pitfalls of Server-Side Rendering
The Challenges and Pitfalls of Server-Side Rendering
The Challenges and Pitfalls of Server-Side Rendering
Server-Side Rendering
Dan Shappir
dansh@wix.com twitter@DanShappir
www.wix.engineering
What Goes
Around Comes
Around
Isomorphic JavaScript
SERVER CLIENT
SSR
HTML
SERVER CLIENT
SSR
Hydrated by Client
HTML
SERVER CLIENT
SSR
SERVER CLIENT
SSR
Framework support
At Wix we
failed twice
before
successfully
implementing
SSR.
Technic Inheren
al t
challeng challeng
es es
window.
✘ (jQuery
)
No DOM
Challenge
#1
Eliminate what you
can.
window.
(jQuery
)
global var
✘
Challenge
#2
Don’t allow mutable
globals.
global var
10 KBPS
Memory
leak
Challenge
#3
10 KBPS
5 min session →
3 MB
Challenge
#3
10 KBPS
24 hours uptime
5 min session →
→
844 MB 3 MB
Tools for the Job
SSR’s
Technical
Challenges
Tests, tests, and more
tests
✔ No DOM
✔ Globals shared
✔ Memory leaks
ESLint Rules
✔ No DOM
✔ Globals shared
Memory leaks
NodeJS tools
No DOM
Globals shared
✔ Memory leaks
Technic Inheren
al t
challeng challeng
es es
Challenge
#1
With CSR
Time To Visible and Time To
Interactive are one and the same.
Challenge
#1
With SSR
They become distinct:
● Time To Visible is improved
● Time To Interactive at best remains the
same
Challenge
#1
Mitigate using Progressive
Hydration
e
Pag
ReactDOM.render(
element1,
container1
);
Fold
ReactDOM.render(
element2,
container2
);
Challenge
#2
Diverges
HTML≠ HTML
Challenge
#2
Unjustified diverges
HTML
HTML
COMPARISON TEST
Challenge
#2
Justified diverges
Placeholder
HTML
So.
SSR can provide very significant
performance boost for dynamic
sites,
specifically Time To Visible.
It’s not trivial
- Test, test, and test again
- Allocate time and resources
- Time to Visible < Time to
Interactive
Thank You
dansh@wix.com twitter@DanShappir
www.wix.engineering