-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(HTML) style_tt()
is very slow
#354
Comments
Which output format? |
Html. I will produce mre once I got some time |
I think the HTML template could really use some improvements: https://github.com/vincentarelbundock/tinytable/blob/main/inst/templates/bootstrap.html Say we try something simple like this: library(tinytable)
tt(head(iris)) |> style_tt(color = "orange") |> save_tt("example.html") You'll see in the raw HTML that every single cell is styled using a separate line of code, to specify the JS/CSS to apply. I bet that this is incredibly inefficient for large tables. In other formats like LaTeX and Typst, we collect all So if I apply "orange" to all cells of a table, the Typst file will have only one array of indices, and it will apply the styling code only once to the full array. In HTML, we call JS functions for every cell separately, one after the other. I have no proof, but I suspect this is inefficient. Roadmap to potential improvement:
This is kind of an ambitious project, but I think it is unavoidable for the future. I hope it will make the HTML faster. It will certainly make the code cleaner. |
Simulation study (and MRE) to see the cost of styling. The cost of styling seems to be going quite linearly. Dunno what is the cause of the drop at the end. Only one repetition was made, so it might be inaccurate. Ideally, the cost of styling should be relatively constant.
|
lol yeah. we need a refactor. |
Here are two versions of a simple table. I'm not sure this will really speed things up, but it will certainly simplify the code. Unfortunately, it'll be a bit of work to implement so we know. |
I have table with ~ 150 rows and I would like to style some columns.
However, when I tried to style a bit too many rows, the
style_tt()
function takes a few minutes.The text was updated successfully, but these errors were encountered: