Conflicting Files ? Failure

User tests: Successful: Unsuccessful:

avatar Dimas555
Dimas555
21 Mar 2019

Transfer of script options generation from the StylesRenderer.php to the ScriptsRenderer.php

avatar Dimas555 Dimas555 - open - 21 Mar 2019
avatar Dimas555 Dimas555 - change - 21 Mar 2019
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 21 Mar 2019
Category Libraries
avatar Quy
Quy - comment - 21 Mar 2019

Please use tabs and not spaces for indentation.

avatar dgrammatiko
dgrammatiko - comment - 21 Mar 2019

@Dimas555 there was a reason why this was left (intentionally) in the stylesRenderer. Basically and plain simple the idea was to leave the scripts renderer free to move to the end of the page (before </body>, eg all script tags to bottom)...

avatar mbabker
mbabker - comment - 21 Mar 2019

Then this needs to move to the meta renderer, or its own renderer, otherwise the styles renderer is stuck in the head and according to some people's best practices having that in the head is wrong.

avatar dgrammatiko
dgrammatiko - comment - 21 Mar 2019

What @mbabker wrote

avatar alex7r
alex7r - comment - 22 Mar 2019

@dgrammatiko @mbabker
Based on your answers I'd like to make sure we are on the same page here:
@mbabker is agree that this block is not supposed to be in the styles;
@dgrammatiko think that this should be in the <head> only;
Please correct me if I'm wrong here.

My opinion:
I agree with initial request: something that belongs to (used by) scripts is supposed to be in scripts.
Basically if we building the modular system for those metas, styles, scripts we should be able to use functionality separately.

Now goes example:
I remove meta and styles (I do not need those, I do not what to allow 3rd party components to influence my template [yes, it's strict to be what I put in there]), but I want to be able to use scripts.
Now i use JText::script('LANG_STRING').
As a result I have empty result for Joomla.JText._('LANG_STRING').
Reason: lang strings are pushed to "script options" which are rendered in styles; and I do not have those. [xtd-buttons, editor settings are also depend on rendering "styles" block this way]

My question:
@dgrammatiko why do you thing that script options should always be rendered in <head>?

avatar rdeutz rdeutz - change - 22 Mar 2019
Labels Added: ?
avatar mbabker
mbabker - comment - 22 Mar 2019

I remove meta and styles (I do not need those, I do not what to allow 3rd party components to influence my template [yes, it's strict to be what I put in there]), but I want to be able to use scripts.

For the record, I think this is a very bad idea. I get the reasoning for style related stuff, but for metadata you've essentially killed off everything in core and every plugin that handles setting page data, a lot of this being your SEO related stuff (which includes basic things like your <title> tag). Realistically you should be pulling things out of the arrays in the Document class before everything is rendered, not excluding rendering completely.

This options element is a bit of a special case in that it is acting as a container to transfer data from the server to the client and that data should be available as quickly as possible, and it needs to come before the scripts actually start being included (so as this PR is it's actually pretty broken because it renders the options element after the rest of the page's JavaScript). IMO this specific <script> tag should remain in the head and not be shuffled around with the rest of the script output.

avatar dgrammatiko
dgrammatiko - comment - 22 Mar 2019

why do you think that script options should always be rendered in ?

Because this is not aa actual script, it's just some json data passed from PHP to Javascript. It can be echoed anywhere in the page but for consistency and actually not creating any problems to the order of execution it's better to stay in the head. This tag is not render blocking so there is no benefit moving it to the scripts renderer.

avatar alex7r
alex7r - comment - 23 Mar 2019

@mbabker I hear you, but still believe the idea that Joomla is something bigger that WP or any other regular website engine. So I might be building the internal custom platform (for example HR platform) that have nothing but login page available for the public and SEs.

@dgrammatiko first of all don't be so sure about the benefit part.
(quick example here: there is cases when SEs are only loading the N bytes of the page, and if you put big JSON with a lot of strings in the head you might run into a issue).
second thing here:
if Joomla makes it modular and possible to play around with this rendering block you actually mean that I can play around with those and put styles after scripts.
(And IMHO that's not something where you can quote Uncle Ben: "With great power comes great responsibility" )
third (and staring) point:
I should be able to use modules independently.

Putting it to the start of the rendering block may make sense, but I still think it should be within scripts block. You can't fight the logic: scripts are using these lines, styles - do not.

avatar Fedik
Fedik - comment - 23 Mar 2019

the changes are wrong,
the <script type="application/json" class="joomla-script-options"> block should be always over all scripts.
I do not really see much reason to moving thing around here, but styles or meta are fine locations for it.

upd: meta sounds logical for this block

avatar alex7r
alex7r - comment - 23 Mar 2019

@Fedik still do not understand how someone find styles for this "fine". I mean if you are willing to put it anywhere just to let it work somehow in the default setup - yes. But as I said I might be reordering scripts and styles, or removing last one at all.

avatar dgrammatiko
dgrammatiko - comment - 23 Mar 2019

@alex7r just use your own renders then

avatar Fedik
Fedik - comment - 23 Mar 2019

still do not understand how someone find styles for this "fine"

It just because of ordering, a styles should always come up first than scripts (if it not, then you doing something wrong).
If someone want to change location of this block then just place it in Meta, and everyone will be happy. It a kind of meta anyway.

But as I said I might be reordering scripts and styles, or removing last one at all.

You may remove anything, but then it not Joomla! issue, it an issue of your project. I think.

avatar alex7r
alex7r - comment - 23 Mar 2019

@Fedik

If someone want to change location of this block then just place it in Meta, and everyone will be happy. It a kind of meta anyway.

As I argued above:

there is cases when SEs are only loading the N bytes of the page, and if you put big JSON with a lot of strings in the head you might run into a issue

And for:

but then it not Joomla! issue

Yes, for 3.x and now for 4.x, since it's allowed by core (by splitting it to a different renderers) modularity.

avatar mbabker
mbabker - comment - 23 Mar 2019

(quick example here: there is cases when SEs are only loading the N bytes of the page, and if you put big JSON with a lot of strings in the head you might run into a issue).

What search engines? And honestly, if they are truly only loading the first N bytes of the HTML document, then they're probably screwing up something anyway because any good search platform today is not only analyzing <meta> and <title> tags found within a <head> element and that behavior implies that they are seeing very little, if any, of what is in your document's <body> (and it gets even worse when you start considering the markup structure for your template which generally is going to include your site title, navigation, and probably a search element; if you're working against a 4 kilobyte limit then a page like https://www.joomla.org/announcements/release-news/5761-joomla-3-9-4-release.html probably doesn't get indexed correctly at all because the body content is so deep into the DOM).

avatar Fedik
Fedik - comment - 23 Mar 2019

there is cases when SEs are only loading the N bytes of the page, and if you put big JSON with a lot of strings in the head you might run into a issue

I did not said the JSON block should be a first ever loaded thing ?
At the end of meta are fine.
Also as @mbabker mentioned that not really good argument. Additionally when site has gzip enabled then someone will get N bites of ?

avatar euismod2336
euismod2336 - comment - 19 Oct 2019

@Dimas555 Could you move this into the MetaRenderer (and fix the conflicts)? that seems to be the most "logical" place for the options

avatar Quy
Quy - comment - 30 Nov 2019

Please fix conflicts.

avatar Quy Quy - change - 17 Jul 2020
Labels Added: Conflicting Files
avatar Fedik
Fedik - comment - 17 Jul 2020

this can be closed, it much changed in j4

avatar Quy
Quy - comment - 17 Jul 2020

Thanks @Fedik

avatar Quy Quy - close - 17 Jul 2020
avatar Quy Quy - change - 17 Jul 2020
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2020-07-17 17:20:55
Closed_By Quy

Add a Comment

Login with GitHub to post a comment