Re: [whatwg] scrap the srcset attribute

On Mon, Mar 2, 2015 at 1:08 PM, Michael A. Peters
<mpeters@domblogger.net> wrote:
> On 03/02/2015 09:47 AM, Tab Atkins Jr. wrote:
>> This is much easier to write and to maintain
>
> Is it really?
>
> With a simple key=value pair, I can:
>
> $src = trim($node->getAttribute('src');
>
> Then I can check it - if it is relative, I can change it to reference the
> cdn. If it is not local, I can check to make the domain is valid, check the
> domain is not in our black list, etc. and then replace the src node with the
> cleaned version.
>
> With srcset - I can still do that but then becomes more complex as there is
> an initial array that then has to be exploded into secondary arrays etc. and
> more complicated code is more prone to bugs.

When designing the syntax, we optimized for authoring and updating by
hand, not for JS-based manipulation.  That's a far lesser use-case.
You shouldn't be sending pages with <img src> that you intend to
change in ways that could be done server-side (all of the things you
mention qualify), as it defeats the preloader and causes users to send
multiple requests, degrading the user-experience significantly for no
real benefit.

> What happens if one of the sources has a typo involving a space, e.g.
>
> Big Image.jpg 2x
>
> instead of
>
> Big%20Image 2x
>
> With key=value that's easy to fix, but it is more complicated when a space
> is a delimiter in an array that is a sub-array.
>
> key=value is kiss and kiss has a lot of benefits.

Then you have an authoring error.  The HTML validator will catch that.
Spaces in filenames are rare, luckily, as are commas, which is part of
why the syntax uses those.

We did consider "simpler" solutions like you're suggesting; they end
up sufficiently verbose and frustrating to write out that it's worth
the added complexity that we settled on.

~TJ

Received on Monday, 2 March 2015 22:27:10 UTC