premailer / css_parser

Ruby CSS Parser
Other
280 stars 110 forks source link

Premailer performance with compressed/minified CSS files #50

Open jpbarbosa opened 10 years ago

jpbarbosa commented 10 years ago

Hi,

Some weeks ago I started having performance problems in my production environment (Heroku) when sending emails with premailer - even using delayed job. Under development environment everything was running fine. My CSS is big, with Bootstrap inside it, and yes, I'm using Bootstrap to add some styles to my email messages.

I started debugging it and, after several tests, I was able to fix the problem using a non-compressed version of my application.css to send emails. This new file, called application-non-compressed.css has the same number of selectors then the original one, the only difference is that the non-compressed version was generate with "config.assets.compress = false" and was not minified.

Heroku delayed job / worker log:

Is there any issue with premailer and big compressed CSS files?

Thanks.

timherby commented 10 years ago

I'm also seeing this issue, and having a heck of a time working around it (since we're using SCSS which really wants to compress the output). Any idea what's causing this performance issue in the parser or did you figure out a workaround?

jpbarbosa commented 9 years ago

Hello @timherby,

As a workaround I created a CSS file called "/public/assets/application-non-compressed.css" and, inside mail.html.erb (template/view used by mailer) I called for it instead "application.css". Like this:

<%= stylesheet_link_tag 'application-non-compressed' %>

The content of application-non-compressed.css was gathered from application.css under development environment with "config.assets.debug = false", so I got the CSS in only one file and not compressed.

Of course, if you change your CSS file you will need to update manually application-non-compressed.css.

I hope I have been clear.