Skip to content

Commit

Permalink
Render table with display: none, then show.
Browse files Browse the repository at this point in the history
This improves the render time for large tables, as it doesn't need to
keep resizing the displayed table as its parsed.
  • Loading branch information
bloodearnest committed Mar 12, 2024
1 parent bb3a7e0 commit 4b54006
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions airlock/templates/file_browser/csv.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{% load airlocktags %}
{% as_csv_data contents as csv_data %}
<div class="inline-block min-w-full align-middle max-w-full">
<table class="datatable">
<div id="csvtable" class="inline-block min-w-full align-middle max-w-full">
<p class="spinner">Loading table data...</p>
<table class="datatable" style="display: none">
<thead class="bg-slate-200" id="csvTable">
<tr>
{% for header in csv_data.headers %}
Expand All @@ -20,3 +21,8 @@
</tbody>
</table>
</div>

<script type="text/javascript">
document.querySelector("#csvtable p.spinner").style.display = "none";
document.querySelector("#csvtable table.datatable").style.display = "table";
</script>

0 comments on commit 4b54006

Please sign in to comment.