How to force code compression?

I like code compression as a demo version.

How to force such code compression using only 5 lines when we see a source within browser?

An example: https://www.a11yproject.com/

there’s no real ‘compression’ there, it’s just removing all the whitespaces. Browsers dont care about whitespace between tags, it’s only humans that care.

regular expression remove \s from your source, and you have “compressed” the code.

Won’t that also remove the spaces that are actually needed, such as in <!DOCTYPE html>?

probably. I was being lazy. :stuck_out_tongue:

replacing [\t\r\n] will get you most of the way. You’ll have some spaces laying around in weird places. If you’re using tabs or line breaks inside tags, you’ve got other problems :stuck_out_tongue:

1 Like

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