Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In newsboxes the plugin CSS is missing #15

Open
frase-git opened this issue Apr 11, 2022 · 13 comments
Open

In newsboxes the plugin CSS is missing #15

frase-git opened this issue Apr 11, 2022 · 13 comments
Labels

Comments

@frase-git
Copy link
Contributor

https://cmsimpleforum.com/viewtopic.php?f=16&p=83801#p83800

@frase-git frase-git added the bug label Apr 11, 2022
@cmb69
Copy link
Member

cmb69 commented Apr 11, 2022

That's a general issue; anything that is written to $hjs during execution of the plugincall is ignored if the plugincall is only triggered by the template after the <head> (in this case newsbox()expand()). The only way around would be to link the CSS uncoditionally, or to require a separate call (e.g. expand_init()) which can be inserted early in the template.

@frase-git
Copy link
Contributor Author

It will probably be best to include the CSS unconditionally.
But an alternative would be to include the CSS in the body, as I did on https://expandcontract.cmsimple-xh.org/?Variante-1. However, the CSS call is always right at the top of the body, which is probably not possible with $bjs.

@cmb69
Copy link
Member

cmb69 commented Apr 11, 2022

We cannot put the <link> at the top of the <body>, but we can put it at the place where the plugin is called, or at the bottom of the <body>. Both is allowed and should yield the same end-result, but there might be a performance/FOUC issue. Adding the preload attribute might mitigate that.

@frase-git
Copy link
Contributor Author

Directly at the plugin call (above), yes that could work well.
Whether the preload still helps at this point? But it will not hurt either.
The CSS call should look like this?
<link rel="preload" href="[file].css" as="style">

@frase-git
Copy link
Contributor Author

Additionally, it would be necessary to prevent the CSS from being loaded multiple times (on the normal page and in the newsboxes).

@olape-git
Copy link
Contributor

combine plugin stylesheet and the optional user stylesheet
https://cmsimpleforum.com/viewtopic.php?f=16&t=18315&hilit=css&start=360#p83420
Or XH_afterFinalCleanUp, but that gives problems again if cnc is used without patch.

@frase-git
Copy link
Contributor Author

In my fork I once implemented a solution that embeds the CSS directly before the plugin.
Changed is only the index.php
This works for me. CSS and JS are loaded only once.

@olape-git
Copy link
Contributor

Why two counters when they both count the same?
CSS in the body? $hjs would be better, right?

@frase-git
Copy link
Contributor Author

Why two counters when they both count the same?

Two counters because they are two different things in two different places. If it were only one, the count would be wrong.

CSS in the body? $hjs would be better, right?

$hjs - that's how it's been so far. But this does not work in newsboxes (see issue title and Christoph's answer).
It has to be in the body - and if possible directly in front of the plugin, so that FOUC is prevented or reduced as much as possible.

With multiple calls (in the page and in newsboxes) the multiple call of CSS and JS must be prevented - hence the counting.

@cmb69
Copy link
Member

cmb69 commented Apr 11, 2022

In my fork I once implemented a solution that embeds the CSS directly before the plugin.

This is now part of PR #12 which is unlikely to be intended. Thus, always create new branches for unrelated improvements/fixes, so they don't interfere. (No need to change anything now; whoever is going to merge that PR can easily skip the second commit.)

@frase-git
Copy link
Contributor Author

This is now part of PR #12 which is unlikely to be intended.

Sorry, but that was the "magic" Github - I didn't want that.

@olape-git
Copy link
Contributor

$hjs - that's how it's been so far. But this does not work in newsboxes (see issue title and Christoph's answer).

It does, with XH_afterFinalCleanUp, see also Swiper_XH.

@cmb69
Copy link
Member

cmb69 commented Apr 11, 2022

It does, with XH_afterFinalCleanUp, see also Swiper_XH.

Ah, right! Still, there should be better (i.e. cleaner) support by the core. It's super common to have the need for this nowadays (since $bjs doesn't cut it anymore).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants