Minifying large HTML, CSS, Javascript files into progmem
Posted: Wed Feb 14, 2018 6:59 pm
I've been looking for a HTML, CSS and javascript minifier/compressor that could convert a whole directory with webfiles in subfolders, and convert them in to smallest possible format. To minimal the storage needed on the ESP.
Without luck...
So I tried it myself using Python https://github.com/Gheotic/ESP-HTML-Compressor.
Which could generates a file with the something like this:
into something like this:
which could be implemented like this:
I do not know if I'm the only one who have been needing something like this, but I hope I could be useful for others too.
I am definitely excited about this!
Without luck...
So I tried it myself using Python https://github.com/Gheotic/ESP-HTML-Compressor.
Which could generates a file with the something like this:
Code: Select all
<!DOCTYPE html>
<html>
<body>
<h1>My First Heading</h1>
<p>My first paragraph.</p>
</body>
</html>
into something like this:
Code: Select all
// /index.html
const char* data_index_html_path PROGMEM = "/index.html";
const char data_index_html[] PROGMEM = {0X3C,0X68,0X74....};
which could be implemented like this:
Code: Select all
server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){
Serial.println("Index.html requested");
request->send_P(200, "text/html", data_index_html);
});
I do not know if I'm the only one who have been needing something like this, but I hope I could be useful for others too.
I am definitely excited about this!