Skip to content

Commit

Permalink
Update sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
slowe committed Sep 12, 2024
1 parent a61d6c9 commit 4790d8f
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ <h1>CSV Editor<span class="v"></span></h1>
<h2>Features</h2>
<ul>
<li>Basic CSV viewer/editor</li>
<li>Lightweight - ??kB required to view a CSV compared to 1.88MB (gzipped) for <a href="https://www.getgrist.com/csv-viewer/">Grist CSV Viewer</a></li>
<li>Lightweight - <span class="size">??</span>kB required to view a CSV compared to 1.88MB (gzipped) for <a href="https://www.getgrist.com/csv-viewer/">Grist CSV Viewer</a></li>
<li>Progressive enhancement</li>
<li>Open source</li>
<li>Easy to install</li>
Expand All @@ -58,7 +58,7 @@ <h2>Features</h2>
</li>
<li>Done!</li>
</ol>
<p>The initial load (<a href="oi.csv.js">oi.csv.js</a>) is under 3kB. Only if someone clicks one of the links is the main script loaded (a further ??kB). By using standard anchor tags, if Javascript is disabled - or fails due to network issues - people will still get the CSV.</p>
<p>The initial load (<a href="oi.csv.js">oi.csv.js</a>) is <span class="size-initial">??</span>kB. Only if someone clicks one of the links is the main script loaded (a further <span class="size-editor">??</span>kB). By using standard anchor tags, if Javascript is disabled - or fails due to network issues - people will still get the CSV.</p>
<p>Try it by clicking <a href="test-data.csv" data-oi-csv>View CSV</a>.</p>
</div>
</div>
Expand All @@ -81,6 +81,18 @@ <h2>Credits</h2>
</footer>
<script>
document.querySelectorAll('.v').forEach(function(el){ el.innerHTML = ' v'+OI.CSVs.version; });
function updateSize(file,q){
fetch(file,{}).then(response => {
if(!response.ok) throw new Error('Network response was not OK');
return response.text();
}).then(txt => {
document.querySelectorAll(q).forEach(function(el){ el.innerHTML = (txt.length/1000).toFixed(1); });
}).catch(e => {
console.error('There has been a problem loading '+file);
});
}
updateSize('dist/oi.csv.js','.size-initial');
updateSize('dist/oi.csveditor.js','.size-editor');
</script>
</body>
</html>

0 comments on commit 4790d8f

Please sign in to comment.