Dependency-free C++ 20 library to minimize HTML
MPL-2.0 License
Quick and dirty dependency-free C++ 20 library to minimize HTML. It removes comments, unnecessary spaces and newlines. As well as fixing some common mistakes base on the HTML5 standard.
The author created this library to minimize the HTML transmitted from his blog. Contributions are welcome.
There's only one API - nanoizepp::minimize
. It takes your HTML string and returns a minimized version of it.
#include <nanoizepp/nanoizepp.hpp>
int main() {
std::string html = "<html> <head> <title>Test</title> </head> <body> <h1>Test</h1> </body></html>";
std::string minimized = nanoizepp::minimize(html);
std::cout << minimized << std::endl;
}
Output:
<html><head><title>Test</title></head><body><h1>Test</h1></body></html>