django-components
django-components copied to clipboard
Out of curiosity - Performance
There is a similar library for rails -> https://viewcomponent.org/ (https://github.com/github/view_component) Apparently that library is 10x faster in rendering than partials, which is the equivalent of django's include.
Do you have any idea what the performance characteristics are for this library?
@jonathan-s That is a great question. I haven't done any benchmarking, but I would expect similar performance metrics as using a normal include. This would be easy to test I think. If you have a template that includes something in a loop, maybe several steps deep, and then at the bottom level, you put an {% include %} and measure performance. Then you replace the bottom level include with a {% component %} call, and compare the loading time.
The motivation for this library was not performance, but rather developer ergonomics in working with components. That said, I would happily accept patches that 1) adds a benchmark and 2) improve performance.
I think we should add a benchmark test in the form of a python script that renders a complex template 1000 times, first with include and then with component, and compares the results. If anyone is able to contribute such a script I'd gladly merge it.