User tests: Successful: Unsuccessful:
When not in debug mode then the output gets minified. The minification will not alter:
Simple answer: less code over the wire!
Here is the proof:
Around 10KB less data to transmit. WIN!
Apply patch, check the html code (in the network tab)
Enable debug, refresh page recheck the page code, size
None, I think
Status | New | ⇒ | Pending |
Category | ⇒ | Libraries |
Labels |
Added:
?
|
Category | Libraries | ⇒ | Administration Templates (admin) Libraries Front End Templates (site) |
That works.
Few questions:
Imho it's not worth minimising stuff during runtime. To much performance impact and risk of failures for almost no gain. But that's a personal view of course.
Isn't preg_replace quite a costly command? I always try to not use regex if not absolutely necessary.
Well nothing is for free in this world :D
What happens if there is intentional whitespace between two tags (eg two ) for whatever reason? This may break layouts (altought not much).
That's invalid HTML and we should not allow it anyways
Obviously wrong answer, for the browser the whitespace, return, tabs, etc have the same weight and result to zero changes in the DOM creation. So if the DOM ignores them how can alter the design?
Imho it's not worth minimising stuff during runtime.
We're not in 2008 anymore and mobile era requires other tricks and best practices, so I'm gonna leave this here:
The full doc from Alex Russell is here: https://infrequently.org/2017/10/can-you-afford-it-real-world-web-performance-budgets/
Obviously wrong answer, for the browser the whitespace, return, tabs, etc have the same weight and result to zero changes in the DOM creation. So if the DOM ignores them how can alter the design?
The browser reduces multiple whitespaces to one. So if you remove all whitespace, that would change it.
We're not in 2008 anymore and mobile era requires other tricks and best practices, so I'm gonna leave this here:
We are almost in 2018 were a few bytes don't matter anymore even on mobile.
But once again, if those bytes matter for your application, then by all means install a plugin which does the minimising. Preferably on a cache and not runtime. There are better solutions already available for those who need it.
We are almost in 2018 were a few bytes don't matter anymore even on mobile.
WOW, you should REALLY read that article, you're misinformed, bytes DO COUNT!
Anyways this is an opt-in (after Micheal's comment), so you can yah your template without any minification, it's not forced anymore!
WOW, you should REALLY read that article, you're misinformed, bytes DO COUNT!
I've read it. The article is about AMP and interactive applications where it is very important that they are very responsive. At least that's what I understood. As I wrote, if you have such requirements for whatever reason, solutions already exist. For regular websites this is way less a concern.
Anyways this is an opt-in (after Micheal's comment), so you can yah your template without any minification, it's not forced anymore!
It's not opt-in. It's enabled for the core templates without any possibility to turn it off. If it starts breaking layouts (on microlevel, but can still be annoying), developers will hate the guy that implemented this...
For regular websites this is way less a concern.
Sorry, you are wrong. Over 70% of the web traffic is from mobile and that article IS about getting a mobile SITE correctly, today. This is !important
will hate the guy that implemented this...
Well, I'm used to it
@C-Lodder pretty sure we can measure it.
EDIT: for the articles page with the 10KB reduction (pictures in the description) the time is:
PC: MacBook Pro (Retina, 13-inch, Late 2013) 2,4 GHz Intel Core i5, 8GB ram, many open IDEs etc
no, please not as default,
it job for plugin or whatever
plus, used regexp looks very "naive", you call it over whole document with possible inline scripts etc
intentional whitespace (more than 1) should be done with
Yes, if more than one whitespace is needed, but you're not removing duplicate whitespace. You're removing all whitespace that is between >
and <
.
A better regex would detect duplicate whitespace and replace it with a single one. Then at least you wouldn't risk breaking layouts. But likely you would save much less bytes then, making it even less usefull.
Sorry, you are wrong. Over 70% of the web traffic is from mobile and that article IS about getting a mobile SITE correctly, today. This is !important
We're not talking about getting a site correctly. It works perfectly fine as it is already.
if more than one whitespace is needed
Right. Have you ever heard about CSS? Using spaces for layout?
It works perfectly fine as it is already.
Right. Open Chrome, go to console->audits and do an audit for joomla.org. It's working fine
Why am I even bother to answer such questions
Right. Have you ever heard about CSS? Using spaces for layout?
Honestly? Are we now trying to say a simple whitespace has to be replaced with CSS? Just so you can replace all whitespace?
Right. Open Chrome, go to console->audits and do an audit for joomla.org. It's working fine
Maybe I miss the point but to me it shows a lot, but from what I see the whitespace isn't the issue there. It actually passes the network payload audit.
gzip compression is very good at exploiting redundancy in strings, that's how it works, so just turn it on. No need to write any (slow) regex code.
Besides, I think there may be edge cases where this gives undesirable results. For example, if I have a couple of words wrapped in their own spans, then the space between the words will be lost. eg.
<span class="first">Go</span> <span class="second">Joomla!</span>
will become
GoJoomla!
instead of
Go Joomla!
@Bakual you can still have whitespace @C-Lodder showcased it above. And you're missing the point, mobile (all of them) are on a tight budget due to bad network, whatever you can save form crapware like jQuery, bootstrap etc and whatever reductions you do server side on the data you send over the wire do make a huge different. We're not building sites for desktops anymore, we have to shift our best practices.
Anyways if this is not appropriate for Joomla I'll just close it, NP. By the way this has been in production for 3years without any glitch.
@chrisdavenport do it like:
<span class="first">Go</span> <span class="second">Joomla!</span>
and you'll still get your space there!
If you didn't repeat the same rant at every opportunity people might be more willing to listen to you.
As for using nbsp - try telling a content creator to do that..they shouldn't need to know about code.
and you'll still get your space there!
Are you expecting end-users to know they must do that, or are you suggesting a change to your regex (which would actually make your string longer instead of shorter)?
I won't go further with this. Keep it as is, it's fine
Status | Pending | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2017-10-30 21:40:56 |
Closed_By | ⇒ | dgt41 |
Honestly, if we're going to do this I'd rather we use proper API endpoints in the
HtmlDocument
class versus an arbitrary behavior based on debug mode being enabled (maybe you have the behavior default on/off based on debug, but having a proper getter/setter is better than relying on a global constant).