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

If <title> tag is missing from the source, Used CSS code is not delivered, causing broken layout #5755

Closed
markonikolic985 opened this issue Feb 10, 2023 · 4 comments · Fixed by #5790
Assignees
Labels
module: critical path css module: remove unused css priority: low Issues that can wait severity: moderate Feature isn't working as expected but has work around to get same value type: bug Indicates an unexpected problem or unintended behavior
Milestone

Comments

@markonikolic985
Copy link

Before submitting an issue please check that you’ve completed the following steps:

  • Made sure you’re on the latest version ✅
  • Used the search feature to ensure that the bug hasn’t been reported before ✅

Describe the bug
We had an edge case where site was broken. After checking the source code, we noticed there is no CSS code/files at all. Also, the <title> tag was missing from the source.

We need <title> tag in order to know where to add Used CSS code. This kind of situations prevents us to do that.

Checking W3's Validator and HTML specs, it might not be obligated to have <title> tag in the head, so we might have more cases like this.

To Reproduce
Steps to reproduce the behavior:

  1. Make sure you don't have <title> tag defined in the source code
  2. Activate "Remove Unused CSS" feature in WP Rocket Settings (Files Optimization tab)
  3. Check pages as not logged in user.
  4. See error, page should be broken and there should not be any CSS code/files in the source

Expected behavior
Used CSS should be generated and delivered to the source code.

@piotrbak piotrbak added type: bug Indicates an unexpected problem or unintended behavior priority: low Issues that can wait module: critical path css severity: moderate Feature isn't working as expected but has work around to get same value module: remove unused css labels Feb 14, 2023
@mostafa-hisham mostafa-hisham added the GROOMING IN PROGRESS Use this label when the issue is currently being groomed. label Feb 17, 2023
@mostafa-hisham
Copy link
Contributor

We are using the end of title tag </title> to make Used CSS load first in case the customer wants to override it
for example, using our filter to exclude CSS files from RUCSS and load it directly.

we also use the end of the title tag </title> in Combine CSS and google fonts optimizations

I checked the head specs document and
and I think the only case that a head tag can be without a title tag is

If the document is an iframe srcdoc document or if title information is available from a higher-level protocol

I also but an HTML document without a title and got an error in the w3 validator

image

@mostafa-hisham mostafa-hisham removed the GROOMING IN PROGRESS Use this label when the issue is currently being groomed. label Feb 17, 2023
@engahmeds3ed engahmeds3ed self-assigned this Feb 28, 2023
@piotrbak
Copy link
Contributor

piotrbak commented Mar 1, 2023

@mostafa-hisham Not sure what's the use case for if title information is available from a higher-level protocol. Would preventing from removal CSS from the source when </title> is missing add much complexity?

@engahmeds3ed
Copy link
Contributor

I discussed this with @mostafa-hisham few days ago and we agreed on that we simply need not to remove styles from the page if there is no title tag there and this will solve the issue of broken layout without touching the html itself, what do u think @piotrbak ?

@piotrbak
Copy link
Contributor

piotrbak commented Mar 1, 2023

@engahmeds3ed Yes, this is perfect solution

@piotrbak piotrbak added this to the 3.13.2 milestone Mar 22, 2023
@piotrbak piotrbak removed this from the 3.13.2 milestone May 4, 2023
@piotrbak piotrbak added this to the 3.13.3 milestone May 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module: critical path css module: remove unused css priority: low Issues that can wait severity: moderate Feature isn't working as expected but has work around to get same value type: bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants