How to automatically format, minify, and obfuscate files?

So I see lots of big websites have code that is minified and obfuscated. How do I do this process automatically, while using an FTP viewer that shows me the unformatted, readable, and unobfuscated code? This will help me decrease storage usage in my website.

For example, let’s say I have this php file

$blablabla = 123
echo blablabla($blablabla)
$bla = ["bla"=>"bla"]
<!DOCTYPE html>

This is how it’s seen in the FTP viewer (see how there are no semicolons), but in the server it looks like this:

<? $q0=123;echo u1($q0);$c2=["bla"=>"bla"]?><!DOCTYPE html><head>blablabla</head><body><p>blabla</p></body>

That’s a size decrease from 150 → 100 bytes. I imagine there would be some thing that works with apache to do this automatically.

Even if there is, we probably don’t have it. And reducing the file size doesn’t necessarily decrease processing time. There are HTML minification options, but I believe those are enabled by our platform by default.


That’s not possible here.

However, you can minify the code yourself before uploading it to the server if you want. The difference in load speed will probably not be noticeable unless your site is huge.


We don’t have any options to automatically minify HTML content on the server. However, we do use Gzip compression by default for all requests, which means that in practice the whitespace in your code hardly consumes any bandwidth because whitespace can be compressed really efficiently.

As far as I can tell, both Apache and NGINX don’t support HTML minification by default and require additional modules to be installed to support it (like Google PageSpeed) which we don’t have.

It’s also possible to do HTML minification from PHP. If you use a CMS or a framework, it may have options to do this.

And if you really want maximum performance, you may want to check out Cloudflare as well. They can also do HTML minification for you, and their CDN will help get files to your visitors faster too.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.