css minification

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Fri Jan 16 10:16:55 PST 2015


On 1/16/15 9:58 AM, Vladimir Panteleev wrote:
> On Friday, 16 January 2015 at 17:40:40 UTC, Andrei Alexandrescu wrote:
>> I just added
>> https://github.com/D-Programming-Language/dlang.org/pull/770, which
>> generates minified css files. This is because in the near future css
>> files will become heftier (more documentation comments, more detailed
>> styles etc).
>>
>> The disadvantage is that now one needs to be online to generate
>> documentation. Thoughts?
>
> I would advise against this. If added, it should be opt-in.

Thanks for the feedback.

> I see the following issues:
>
> - The service in question might be occasionally down, or might be shut
> down completely at some point. This makes it an additional point of
> failure.

To counter that I was thinking of:

curl -X POST -s --data-urlencode 'input@$<' http://cssminifier.com/raw 
 >$@ || cp $< $@

This is nice modulo possible delays due to slow timeouts.

I should also add that we already connect online to fetch LATEST from 
github. Incidentally today that takes forever :o).

> - High website load or poor Internet speeds will increase the time
> needed to build the website.

Actually that's not the case in my experience. Did you build the site 
recently, i.e. with dub in tow? Build time is dominated by running dub, 
and it's impossible to run it on only the modified portions of the site. 
make -j on my laptop takes one full minute without doing anything 
online. Running a few curls in parallel with that have plenty of time to 
finish.

Then dub generates 286 MB worth of stuff, which takes a long time to 
rsync. (For perspective: the pre-dub site, images and all, was 19 MB.) 
I'm not sure whether rsync gets further confused by the necessity of 
wiping all files and generating them again, whether they're identical or 
not.

I confess I'm unhappy with dub. I was hoping for a turnkey solution that 
also opens up new possibilities. Sadly it adds its own problems, and 
those it solves I know how to do simpler with ddoc and tooling around 
it. As things are, I found myself with another project in my lap that I 
need to babysit.

> - We can't know for sure that at some point the owners of
> cssminifier.com won't decide to inject evil code in the output. Even if
> you trust the owners, the service might get hacked with the same outcome.

Good point. We could, of course, store the converted css and inspect it 
before uploading, but seems a bit like meteor insurance to me.

> - As the request goes over HTTP, you also need to trust every peer
> between your machine and the website to not perform a MITM attack.
>
> I think relying on a random 3rd-party service is acceptable for an
> amateur or hobbyist website, which we are not. Instead, I suggest adding
> an optional (opt-in) rule which invokes an offline CSS minifier.

That's a rather dim view of online services :o). What would be a 
trustworty offline CSS minifier?

Overall I'm unconvinced of your arguments and I think we should move 
forward with 
https://github.com/D-Programming-Language/dlang.org/pull/770 or a 
variation thereof.


Andrei



More information about the Digitalmars-d mailing list