Optimise email CSS for speed with Premailer
Speed up emails-on-push by removing all descendant selectors from the CSS they use, which can make the CSS inlining much more efficient in certain cases. (More detailed explanation in the commit message.)
To test this, I created a test repo on my local GitLab instance and then wrote a hacky script to benchmark the results with and without CSS inlining. I did this on three different commits: a small Ruby change, a commit that adds a single copy of jQuery, and a commit that adds two copies of jQuery. The benchmarking obviously isn't particularly accurate, but that isn't a huge deal as the changes are so big.
user system total real
small_ruby_change 2.710000 0.590000 3.300000 ( 3.336362)
small_ruby_change_old_css 0.360000 0.010000 0.370000 ( 0.378296)
small_ruby_change_new_css 0.310000 0.020000 0.330000 ( 0.327902)
1_jquery 3.830000 0.740000 4.570000 ( 4.749138)
1_jquery_old_css 523.080000 9.860000 532.940000 (586.731826)
1_jquery_new_css 23.230000 0.230000 23.460000 ( 23.640816)
2_jquerys 4.880000 0.770000 5.650000 ( 5.779586)
2_jquerys_old_css 9474.300000 96.260000 9570.560000 (10497.539961)
2_jquerys_new_css 42.320000 0.590000 42.910000 ( 43.954763)
(I don't know why I said 6 hours in the other issue, it was actually 2.5. It just felt like 6
The output email HTML is identical in each case, as well:
$ diff tmp/mails/small_ruby_change_old_css.html tmp/mails/small_ruby_change_new_css.html
$ diff tmp/mails/1_jquery_old_css.html tmp/mails/1_jquery_new_css.html
$ diff tmp/mails/2_jquerys_old_css.html tmp/mails/2_jquerys_new_css.html