Jump to content

MinifyPageRender


thausmann
 Share

Recommended Posts

I looked at my HTML output today and all this chaotic whitespace triggered my OCD.

This module simply hooks into Page::render and removes whitespaces from frontend HTML with a simple regex replace.

I mostly put this together for cosmetics. I like my View source neat and tidy.
This is not well tested yet, please open an issue if you run into problems.

GitHub: https://github.com/timohausmann/MinifyPageRender

 

screenshot.png

  • Like 7
Link to comment
Share on other sites

  • 11 months later...

I don't think of myself as OCD, but I sure do love me some minified HTML!

I used this module on a recent project and it was plug and play simplicity. But now when I try to install it (after uploading directly to modules or as a zip file), I get a compile error:

Look out… Compile Error: Cannot declare class MinifyPageRender, because the name is already in use (line 5 of site/modules/MinifyPageRender/MinifyPageRender.module)

This is running ProcessWire 3.0.210 and the same thing happens with debug mode on or off.

Any clue why this might happen?

Link to comment
Share on other sites

At first it did sound like a namespace issue but the module has a namespace so I threw it in a demo instance:

No issues so far. Installed without errors, output is minified.

ProcessWire 3.0.210, PHP: 7.4, 8.0, 8.1

2023-06-09_15-12.thumb.png.79b58902455970f9781f68e051e6ac13.png

@ZAP Can you please check that there is no other copy of that module in place. Maybe with a different folder name or something.

  • Thanks 1
Link to comment
Share on other sites

Quote

@ZAP Can you please check that there is no other copy of that module in place. Maybe with a different folder name or something.

Yes! That was it. I somehow had a copy of the module in both wire/modules/ and also site/modules/. I also had a permissions issue (I couldn't delete the extra one until I changed its permissions), but I think that the issue was just that it was in there twice. Maybe the core should check for that when refreshing for new modules? It's kind of a dumb thing to do, and I shouldn't expect PW to keep me from doing dumb things.

Can I say how awesome it is that two people investigated this issue for me just since I posted last night? I'm accustomed to forums where replies can take quite a while and may not be all that helpful. I appreciate the energy and solidarity! I'll look for some posts that I may be able to help with as soon as I get done with my day job today. 

  • Like 1
Link to comment
Share on other sites

15 minutes ago, ZAP said:

Maybe the core should check for that when refreshing for new modules? It's kind of a dumb thing to do, and I shouldn't expect PW to keep me from doing dumb things.

It actually does... just tested it.

2023-06-09_18-45.thumb.png.e7bc7e6eb73d00033cc5adc983d36e3d.png

But you can - as always - actually miss it. The first time ProcessWire notices this, it's a large notification... from then on it's somewhere hidden.

2023-06-09_18-47.thumb.png.7831d4668efd9289812f611a448cc069.png

The good thing: most of the time this isn't really an issue.

 

19 minutes ago, ZAP said:

Can I say how awesome it is that two people investigated this issue for me just since I posted last night?

Well... yeah, this community is probably one of the best you can find. But to be honest and fair here, not all questions are that easy to solve. Some take a bit more time.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...