When you ask ChatGPT to create an HTML site, the code can gradually grow larger as you continue making revisions.
Existing HTML minification tools are excellent for reducing file size. However, relatively few are designed with ChatGPT-based analysis and re-editing in mind, which makes them less suitable for this kind of workflow.
That is why I created a tool that can minify HTML while keeping it as easy as possible for ChatGPT to analyze.
In this article, I will refer to “minification” as “cleanup” for convenience.
Cleanup is intended to slightly reduce file size and token usage when repeatedly making revisions.
Compression is intended to reduce file size when sharing HTML in a chat, assuming the recipient only needs to open the file and does not need to edit it.
※Because the cleanup process is performed mechanically, there is no guarantee that it will never introduce bugs. Always check that the HTML works correctly after cleanup.
👇 Try the site here
https://uni928.github.io/Uni928PublicHTMLs2/index2English.html
Features
This tool has three modes.
- Safe
Compresses the file without modifying the contents of the HTML, CSS, or JavaScript.
- Experimental
Cleans up consecutive whitespace, comments, and similar elements before compressing the file. This mode is suitable when sharing HTML in a chat and you believe the recipient is unlikely to read the source code directly.
- Clean Only
Only cleans up consecutive whitespace, comments, and similar elements, then saves the result as a regular HTML file without self-extracting compression. This mode is recommended when publishing the file on a web server.
There are many third-party tools that can achieve more aggressive cleanup. However, this tool prioritizes keeping the HTML as easy as possible for ChatGPT to analyze while minimizing its impact on reasoning.
It Can Also Be Used in Conversations with ChatGPT
When you repeatedly ask ChatGPT to revise an HTML file, its size tends to grow because of comments, whitespace, and newly added code.
With this tool, the parts that are cleaned up can often achieve a perceptible file-size reduction of around 15%, depending on the HTML.
Code generated by ChatGPT is often relatively readable and well structured to begin with.
If you only reduce unnecessary whitespace and comments, most of the actual code remains unchanged. Therefore, I believe the impact on reasoning is also relatively small.
For these reasons, when passing the HTML to ChatGPT again, this tool is expected to provide the following benefit:
Slightly reduce input/output token usage while keeping the impact on reasoning relatively small.
The reduction in output applies when asking ChatGPT to generate the entire revised HTML file.
This does not necessarily apply when asking it to generate only part of the file.
I have added the following prompt to my ChatGPT custom instructions:
- Don't reformat minified HTML.
Choose a Mode Based on Your Use Case
If you are only sharing an HTML file in a chat and the recipient probably does not need to read its contents directly, you can use Experimental mode to reduce the file size further.
On the other hand, when distributing a file through a web server, compression such as gzip or Brotli is often performed automatically. For that reason, self-extracting compression is generally not recommended.
In such cases, I recommend using Clean Only to reduce the size of the HTML itself before publishing it.
You only need to drag and drop the file, so if you frequently create and revise HTML with ChatGPT, please give it a try.
👇 Try the site here
https://uni928.github.io/Uni928PublicHTMLs2/index2English.html
For Those Who Want to See the Code
👇 GitHub
https://github.com/uni928/Uni928PublicHTMLs2/blob/main/index2English.html
The GitHub URL is provided for anyone who wants to visually inspect the source code and check for potentially malicious code.
Although it is not possible to perform a completely exhaustive review, another useful approach is to download the file, attach the code to ChatGPT, ask it to check for potentially malicious code, and then use it locally.
I also recommend using ChatGPT or similar tools to tune the site so that it works better for your own needs.
If you create a more convenient site, I would be happy to use it as well, so I would appreciate it if you made it publicly available.
If you publish a modified version of this repository rather than rebuilding it completely from scratch, please follow the terms of the MIT License when distributing it. This includes retaining the copyright notice and the MIT License text.
Top comments (0)