Skip to content
This repository has been archived by the owner on Apr 21, 2023. It is now read-only.

pedantic filter should prevent inlining CSS into the body #1153

Closed
ghost opened this issue Oct 9, 2015 · 6 comments
Closed

pedantic filter should prevent inlining CSS into the body #1153

ghost opened this issue Oct 9, 2015 · 6 comments

Comments

@ghost
Copy link

ghost commented Oct 9, 2015

Automatic CSS inlining leaves <style> tag inside <body>, making the pages invalid.

@ghost ghost changed the title Problem with CSS embedment CSS embedment makes pages invalid Oct 9, 2015
@jeffkaufman
Copy link
Contributor

I'm not sure what you're asking. Can you give an example of a page with this problem, showing what it looked like originally and what it looked like after PageSpeed modified it?

@ghost
Copy link
Author

ghost commented Oct 25, 2015

Example:

<body>
  <p>blablabla</p>
  <link rel="stylesheet" property="stylesheet" href="https://something/whatever.css" />
</body>

will be modified to

<body>
  <p>blablabla</p>
  <style property="stylesheet">
    // Something
  </style>
</body>

I think you just don't know what "valid" means. "Valid" here means passing the W3C validator.
This is not a big problem, but if it doesn't inline styles in the <body> tag, it will be very useful for those who are requested to make the page "valid" like me.

@jmarantz
Copy link
Contributor

Inlining CSS has substantial benefits to web-site latency which is the main goal of PageSpeed. In some cases, W3C validators flag constructs that are supported by all browsers, and PageSpeed has a choice as to whether to optimize for the validator or optimize for the end-user. By default, PageSpeed has prefers optimizing for the end-user.

PageSpeed also has a 'pedantic' filter which, if specified, ought to avoid having PageSpeed introduce new validator violations in the page. However, it probably doesn't cover this case, and that's a bug.

You probably want to turn the pedantic filter when running validators. So when you type your URL into w3c validation tool, you can append:
?PageSpeedFilters=+pedantic
If you don't like that idea, and want your site valid all the time, then you can put
ModPagespeedEnableFilters pedantic
into your pagespeed.conf, which will make your site slower.

And having said that, I believe this case is not covered by the 'pedantic' filter, and I'm wording this bug title to reflect that.

Old title: CSS embedment makes pages invalid

@jmarantz jmarantz changed the title CSS embedment makes pages invalid pedantic filter should avoid inlining CSS into the body Oct 25, 2015
@jmarantz jmarantz changed the title pedantic filter should avoid inlining CSS into the body pedantic filter should prevent inlining CSS into the body Oct 25, 2015
@jmaessen
Copy link
Contributor

My understanding had been that elements in were also forbidden by validation – does the original page validate?

@jeffkaufman
Copy link
Contributor

The pedantic filter inserts some things that are required by html4 but not html5. So we might need a pedantic5 filter for this case.

@ghost
Copy link
Author

ghost commented Oct 25, 2015

Original page with that kind of <link> validates.

ashishk-1 added a commit to ashishk-1/incubator-pagespeed-mod that referenced this issue Jul 27, 2017
…enabled. This is to maintain w3c validation of page. Bug fix apache#1153
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants