I have a Django website that displays a table with data. It uses FontAwesome and Bootstrap for styling – which leads to some lengthy HTML (a standard page is 136k).
Eg Some TDs contain an arrow using FA and a style to rotate it eg
<i class="fa-solid fa-arrow-down fa-lg fa-rotate-by" style=--fa-rotate-angle:282deg></i>
Is there a way to minify or some how reduce the name sizes?
I have been reading about webpack and gulp minifiers but I cannot find anything that mentions the use of 3rd party assets like FA and BS and how one might reduce their name sizes. Also these seem somewhat targeted to client-side frameworks rather than server-side which mine is.
2
Answers
By HTML Minification
from htmlmin.minify import html_minify #import minify
class Minify:
Alternatively, by HTTP compression, if the intent is not to obfusticate your code at the browser end but to reduce bandwidth consumed. Django comes with gzip middleware, or there’s django-compression-middleware. which suppports other compression methods.
I believe, but haven’t measured, that HTTP compression will save more bandwidth than minification. It’s also install-and-forget.