Skip to content

Instantly share code, notes, and snippets.

View galeksandrp's full-sized avatar

Alexander Georgievskiy galeksandrp

View GitHub Profile
@mojaray2k
mojaray2k / Trickshots 1
Last active May 16, 2022 16:45
Use jQuery to send a HEAD request with AJAX and get the size of a file without downloading it. This snippet places the size of the file in braces next to its name. The script issues a HEAD request, which only returns the headers and not the actual content of the file, which means that these requests are fast and lightweight.
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Display files sizes next to download links</title>
</head>
<body>
<a href="001.html" class="fetchSize">First Trickshot</a>
<a href="034.html" class="fetchSize">This Trickshot</a>
<a href="ball.png" class="fetchSize">Ball.png</a>