News for hackers. Stuff that matters.
Re:How a new HTML element will make the Web faster by eurleif on Tuesday September 02, 2014 @01:05AM (#8255908)
<picture> is responsive; when you change the viewport's width, the browser can load a differently-sized version of the image. How would JS be made responsive like that? Once one version of a script is loaded, you can't magically replace it with a difference version.

Of course, you could limit the media queries that could be used with JavaScript, but then your general solution isn't really so general anymore. And there's already a way to dynamically load scripts, so we don't really need another way to do that:

    <script>
    if (blah) {
        document.write('<script src="a.js">');
    } else {
        document.write('<script src="b.js">');
    }
    </script>
And there's also already a way dynamically load CSS (using media queries, even):

    <style>
    @import url(a.css) (max-width: 800px);
    @import url(b.css) (min-width: 801px);
    </style>
Re:How a new HTML element will make the Web faster by hrjet on Tuesday September 02, 2014 @01:11AM (#8255918)
Good point about JS.

But there are potentially more types of media (audio, video, html via frames, etc).

Even if a general solution isn't applicable to JS, it can have lots of other uses.

Re:How a new HTML element will make the Web faster by eurleif on Tuesday September 02, 2014 @01:56PM (#8259079)
>html via frames

That has the same problem as JS, especially when you realize that framed pages on the same domain can interact with the parent's DOM.

Re:How a new HTML element will make the Web faster by tg3 on Tuesday September 02, 2014 @01:20AM (#8255932)
the <picture> tag is set up very similarly to the audio and video tags, so I think that even if this specific solution isn't general, the pattern can be applied generally to other types of media.