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

pedantic filter should prevent inlining CSS into the body #1153

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

Comments

Projects
None yet
3 participants
@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

This comment has been minimized.

Copy link
Contributor

jeffkaufman commented Oct 23, 2015

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

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link
Contributor

jmarantz commented Oct 25, 2015

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

This comment has been minimized.

Copy link
Contributor

jmaessen commented Oct 25, 2015

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

@jeffkaufman

This comment has been minimized.

Copy link
Contributor

jeffkaufman commented Oct 25, 2015

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

This comment has been minimized.

Copy link

ghost commented Oct 25, 2015

Original page with that kind of <link> validates.

ashishk-1 added a commit to ashishk-1/mod_pagespeed that referenced this issue Jul 27, 2017

Dont inline css from style link element in body when pedantic filter …
…enabled. This is to maintain w3c validation of page. Bug fix apache#1153

@ashishk-1 ashishk-1 closed this in 354bc7e Sep 11, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment