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

css content dumped into style tag after premailer compile #334

Open
slucaskim opened this issue Jan 18, 2017 · 2 comments
Open

css content dumped into style tag after premailer compile #334

slucaskim opened this issue Jan 18, 2017 · 2 comments

Comments

@slucaskim
Copy link

slucaskim commented Jan 18, 2017

Is there any reason why the following html:

...
<head>
    <meta content="charset=utf-8"/>
    <%= stylesheet_link_tag "url" %>
</head>
...

should result in this after premailer performs to_inline_css?

...
<style type="text/css">
@-webkit-keyframes panel-slide-up {

}
@keyframes panel-slide-up {

}
...
</style>
...

Premailer inlines all the relevant css correctly, but also creates a huge style tag with irrelevant css from the original stylesheet. This is causing a problem for me as the resulting html becomes too big and email clients clip the message.

In what cases does Premailer create a style tag?

I am using all default configuration settings, so options like "include_style_tags" is false.

soundasleep added a commit to soundasleep/premailer-rails that referenced this issue Oct 17, 2018
Premailer very happily generates email with thousands of unnecessary
lines in the inline <style> tag, which means that at some point, some
email clients (particularly Gmail) will refuse to render the email, and
will instead clip the email with "[Message clipped] View entire
message".

It seems this clip is around ~100 KB of inline <style> tags.

This new config option, :drop_inline_style_tags, will take the generated
`to_inline_css`, and drop the <style> tag completely. In theory, this
shouldn't have any impact, beacuse all of the relevant CSS will have
been applied to the elements themselves anyway.

Resolves issues such as:
- premailer/premailer#334
- fphilipe#192
- fphilipe#184
soundasleep added a commit to soundasleep/premailer-rails that referenced this issue Oct 17, 2018
Premailer very happily generates email with thousands of unnecessary
lines in the inline <style> tag, which means that at some point, some
email clients (particularly Gmail) will refuse to render the email, and
will instead clip the email with "[Message clipped] View entire
message".

It seems this clip is around ~100 KB of inline <style> tags.

This new config option, :drop_inline_style_tags, will take the generated
`to_inline_css`, and drop the <style> tag completely. In theory, this
shouldn't have any impact, because all of the relevant CSS will have
been applied to the elements themselves anyway.

Resolves issues such as:
- premailer/premailer#334
- fphilipe#192
- fphilipe#184
@soundasleep
Copy link

I've tried to resolve this in the premailer-rails gem (which uses premailer) with a new config option: fphilipe/premailer-rails#227

@bborn
Copy link
Contributor

bborn commented Apr 17, 2019

Here you go: #374

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

No branches or pull requests

3 participants