Asset management

General discussion of development ideas and the approaches taken in the 3.x branch of phpBB. The next feature release of phpBB 3 will be 3.3/Proteus.
Forum rules
Please do not post support questions regarding installing, updating, or upgrading phpBB 3.2.x. If you need support for phpBB 3.2.x please visit the 3.2.x Support Forum on phpbb.com.

If you have questions regarding writing extensions please post in Extension Writers Discussion to receive proper guidance from our staff and community.
User avatar
brunoais
Registered User
Posts: 964
Joined: Fri Dec 18, 2009 3:55 pm

Re: Asset management

Post by brunoais »

@callumacrae Please explain their invalidity. What is invalid and why it is invalid, otherwise, I won't understand.
Also, phpBB's apparent load time cannot be reduced by minimizing the js due to how everything is setup.

@CHItA
By minimizing the files with those techniques, the resulting file is 1 file with all the files that actually exist. For CSS... Well... that's maybe easier with the @include directive but... In which order should each stylesheet be read in? Trial and failure? Analyze the script that does the merging job?
Then... What about the js? There's no include with javascript... How do you solve? Javascript code to generate the script tags in the right order?

The only viable alternative I can see is to install npm + UnuglifyJs and let it run there. But that brings us back to the beginning where it requires more tools to be able to edit phpBB's code.

Do note that I'm not against consumer phpBB versions coming with the minified versions, ready to use, done by whatever tool is the most advanced or trending at time of build. Actually, I do think that's quite nice and a good practice.
What I'm against is the said versions not being ready for someone with minimal knowledge on HTML+CSS markup (and maybe js copy & paste) and no knowledge on PHP, not being able to edit and see the results right away (after switching on the "Recompile stale style components" in the ACP).
I'd say the most annoying thing would be to edit the HTML and get results but get none when editing the CSS.
We may also have 2 builds, one with the asset manager and another without but I think that would be a source of confusion to some people.

Now that I think, there's 1 thing I didn't understand properly:
Would the development version (the ones on github) include the minified versions such that the developer who changes the code has to generate the minified versions or would they only be minified at build&deploy time?

CHItA
Development Team
Development Team
Posts: 162
Joined: Thu Mar 12, 2015 1:43 pm
Location: Budapest, Hungary

Re: Asset management

Post by CHItA »

I guess it would be on deployment, as minified versions are hard to review.

What I mean by inclusion code btw, is

Code: Select all

<link src="" />
<script src="">
which should be easy to find. Also you could possibly add you modifications to a separate file, and add that. I think implementing any minifier support in the core (ACP or wherever) is just unnecessary overhead and work. IMO if you modify something yourself, you take the risks that it won't be that optimized, and I think that is fine.

User avatar
brunoais
Registered User
Posts: 964
Joined: Fri Dec 18, 2009 3:55 pm

Re: Asset management

Post by brunoais »

Speaking on speeds,
I've been doing in the last 1.5h multiple speed tests (when I was able to) to https://area51.phpbb.com/phpBB/viewtopi ... 6&start=10 in a 2G connection both in firefox 38.0.1 and chrome 43.0.2357.81 with only the ABP extension. I used the ABP to block the /analytics.js that is in the <head> which was ruining my tests. I got some interesting numbers and results.

1st thing I noticed is that Chrome does not show area51 until all CSS registered in the <head> and @include'd is not finished loading, which, IMO, sucks hard and makes the visual test harder to work on.

Moving on to the interesting results:
All these tests were made in a real 2G connection with ~200Kb/s download and ~20Kb/s of upload and a very stable connection (I don't know how to simulate unstable connections).
These were made with the cache turned off, the times are relative to the initial page request:

It took ~5s to get enough HTML to see the page is loading.
After ~7s, I could already see the top posts (it was showing faster than I could scroll) and some basic styling was already in effect.
After ~10s, the page had most styles in.
After ~11s, the page had all styles in.
Note: The individual style files had been waiting for 7 png images to be loaded (the ones on the top of the page).
After ~10s the js files are queued for download (they are waiting).
After from ~13s to ~14s core.js loads. It takes 1.3s to load 43KB.
After ~15s or ~20s (I couldn't get consistent results here) ajax.js would finish loading.
Note: The individual js files had been waiting for 3-4 .gif images to load.
It took ~30s for the load event to fire and the page to be fully loaded.

I also made some tests with the cache turned on. I didn't take file speeds into account and I noticed that the browser was painting using the cached versions of the CSS even before the updated versions came from the requests. Chrome seemed to be doing the same.

There's 1 thing I love in phpBB, even without js, nearly all looks and feels the same way as if it had js working. For me, that's great.

In my opinion, we can make phpBB apparent loading time quite short just by merging the .css files and without doing any minimization at all. The js files do not bother the loading process (in area51, though, that analytics.js without the @defer is troublesome for slow internet speeds) because phpBB looks fully loaded before that and while the user is reacting and locating what he needs, meanwhile, the js loads fully. Regardless of that, concatenating all js is good enough for the current state, even without any resort to minimization.
Now, if files are minimized, it should become better, certainly, but I'm quite certain you won't be able to shave seconds out of the full loading time compared to just merging the files and gzipping them.
CHItA wrote:I guess it would be on deployment, as minified versions are hard to review.
OK. That's what I was expecting and what I agree to have.
CHItA wrote: What I mean by inclusion code btw, is

Code: Select all

<link src="" />
<script src="">
which should be easy to find. Also you could possibly add you modifications to a separate file, and add that. I think implementing any minifier support in the core (ACP or wherever) is just unnecessary overhead and work. IMO if you modify something yourself, you take the risks that it won't be that optimized, and I think that is fine.
I think you got something wrong here.
IIRC, phpBB would be served with both minified and non-minified versions of the files. The user wants to modify (not add new(!)) the existing code. If he modifies the original file, he would probably want to have it working right, immediately after. Using that technique, it would mean that whatever code he makes, it would be code to override the original one which may or may not work.
Do you get what I'm saying here?

User avatar
DavidIQ
Customisations Team Leader
Customisations Team Leader
Posts: 1834
Joined: Thu Mar 02, 2006 4:29 pm
Location: Earth
Contact:

Re: Asset management

Post by DavidIQ »

It would be very very rare that anyone would want to edit the js included with phpBB, from what I've seen. The included JS code is typically used just so the forum works properly and most people will want to add more JavaScript, not modify the already existing one. I wouldn't worry much about that, if at all.
Image

CHItA
Development Team
Development Team
Posts: 162
Joined: Thu Mar 12, 2015 1:43 pm
Location: Budapest, Hungary

Re: Asset management

Post by CHItA »

@brunoais:
Yes, I've got that. However, I think you're assuming that if the user would modify something, he/she would care to use the ACP to minify assets, meanwhile he/she is unable to modify the asset path to the non-minified version, that's just sounds unrealistic to me.

So I still think, that adding a minifier to ACP or wherever is a waste of time, money and donkeys. Basically that is my opinion regarding this issue.

User avatar
brunoais
Registered User
Posts: 964
Joined: Fri Dec 18, 2009 3:55 pm

Re: Asset management

Post by brunoais »

Yeah.... And I'm giving way less weigh to js than CSS also because of how frequent it is modified. The one that is most modified (when anything is modified) is the HTML + CSS combo.
Anyway, what I also forgot to mention is that I believe this can be used to potentially make extensions that act on the interface not seem to slow phpBB down as much. It can allow having all CSS from all extensions merged into a single file and minimized (even if not squeezed to minimum size).
Now that I think of it, this could be intelligently used such that assets that are not required for the active page can be activated to be preloaded before reaching a probable page. This is just an idea, regardless.

I also think that gzipping would be a very useful process in addition to minification. Tbh, gzip is way more powerful at reducing the file size than minimizing, we should use that at our advantage.
CHItA wrote:Yes, I've got that. However, I think you're assuming that if the user would modify something, he/she would care to use the ACP to minify assets
Wait, what? No! The way to update the minimized version is to reload the relevant page, just that; just like it is now if you modify any template file (except there's no minimized version yet, but I think I make the point).

On another note, we should make use of HTTP cache cache-control;max-age for the static assets. As each version has an unique URL, it doesn't really make any sense to not use it.

User avatar
callumacrae
Former Team Member
Posts: 1046
Joined: Tue Apr 27, 2010 9:37 am
Location: England
Contact:

Re: Asset management

Post by callumacrae »

CHItA wrote:I guess it would be on deployment, as minified versions are hard to review.
Source maps!

They're supported by every JavaScript minifier ever, and none of the PHP ones.
Made by developers, for developers!
My blog

CHItA
Development Team
Development Team
Posts: 162
Joined: Thu Mar 12, 2015 1:43 pm
Location: Budapest, Hungary

Re: Asset management

Post by CHItA »

callumacrae wrote:
CHItA wrote:I guess it would be on deployment, as minified versions are hard to review.
Source maps!

They're supported by every JavaScript minifier ever, and none of the PHP ones.
I meant the GitHub repo, but luckily I don't have to review anything, therefore I don't really care. As I said, I think adding some PHP code to minify assets does not worth the effort IMO (also, if none of PHP libs work well enough, then I guess that's just makes my argument stronger).

User avatar
callumacrae
Former Team Member
Posts: 1046
Joined: Tue Apr 27, 2010 9:37 am
Location: England
Contact:

Re: Asset management

Post by callumacrae »

CHItA wrote:
callumacrae wrote:
CHItA wrote:I guess it would be on deployment, as minified versions are hard to review.
Source maps!

They're supported by every JavaScript minifier ever, and none of the PHP ones.
I meant the GitHub repo, but luckily I don't have to review anything, therefore I don't really care. As I said, I think adding some PHP code to minify assets does not worth the effort IMO (also, if none of PHP libs work well enough, then I guess that's just makes my argument stronger).
Ah, I get you. We'd just save both the minified and unminified code.
Made by developers, for developers!
My blog

User avatar
brunoais
Registered User
Posts: 964
Joined: Fri Dec 18, 2009 3:55 pm

Re: Asset management

Post by brunoais »

callumacrae wrote:
CHItA wrote:
callumacrae wrote:
CHItA wrote:I guess it would be on deployment, as minified versions are hard to review.
Source maps!

They're supported by every JavaScript minifier ever, and none of the PHP ones.
I meant the GitHub repo, but luckily I don't have to review anything, therefore I don't really care. As I said, I think adding some PHP code to minify assets does not worth the effort IMO (also, if none of PHP libs work well enough, then I guess that's just makes my argument stronger).
Ah, I get you. We'd just save both the minified and unminified code.
Do the devs have to minify it or is it automatic?

BTW, you still didn't answer:
brunoais wrote:@callumacrae Please explain their invalidity. What is invalid and why it is invalid, otherwise, I won't understand.
P.S. About the LESS in php, I linked to the wrong thing.
https://github.com/oyejorge/less.php <- That's the updated and kept-updated one. It includes sourcemaps. That means that the sourcemaps issue is now solved and is no longer a reason to invalidate this.

Post Reply