Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #20052

Re: Parallel Download Abstraction

Message-ID <1672892.tfqf7eurea@PointedEars.de> (permalink)
From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Organization PointedEars Software (PES)
Date 2013-05-30 05:13 +0200
Subject Re: Parallel Download Abstraction
Newsgroups comp.lang.javascript
References <09cc7047-18cd-4c88-8093-8b699dbc5ff3@k6g2000yqh.googlegroups.com> <3159554.1y7rF9eUTa@PointedEars.de> <f50022ff-b69e-4edf-a563-14b6490485a8@gw5g2000vbb.googlegroups.com>

Show all headers | View raw


Michael Haufe (TNO) wrote:

> Thomas 'PointedEars' Lahn wrote:
>> Michael Haufe (TNO) wrote:
>> > Will the following perform the same parallel download semantics if it
>> > is abstracted into a different file?
>> > 
>> > ...
>> > <script>
>> > document.write("<script src='script1'></script>")
>> > document.write("<script src='script2'></script>")
>> > </script>
>> > <body>
>> > </html>
>> > 
>> > becoming:
>> >
>> > <script src='writeTwo'></script>
>> > </body>
>> > </html>
>>
>> Yes, it will also _not_ achieve “parallel download”.
> 
> Did you say "also", because I forgot to escape the </script> tag for
> this post, or is there another reason as well?

Please do not top-post.

I said “also” because it is unlikely that either of the two approaches will 
result in “parallel download”.  Scripts, when included this way, are always 
processed sequentially, and AFAIK are also downloaded sequentially:

<https://developers.google.com/speed/articles/include-scripts-properly>

Usually it is a bad idea to use document.write() to include content, 
particularly script content, nowadays:

<https://developers.google.com/speed/docs/best-practices/rtt?hl=en#AvoidDocumentWrite>

A possibility for parallel download is asynchronous XHR using two different 
XHR instances, and inserting “script” elements with the resource's content 
each upon completion, as I do synchronously in jsx.importFrom():

<http://PointedEars.de/websvn/filedetails.php?repname=JSX&path=/trunk/object.js>

(Changing that to asynchronous loading is accomplished by simply passing 
“true” instead of “false” for the third argument.  I shall work on that;
to date it did not occur to me that it could be useful to load scripts 
asynchronously.)


I did not comment on the missing escaping of </script> because from your 
<script> tag I assumed that you would use HTML5, and I assumed that because 
it is not SGML-based, escaping of “</” was no longer necessary there.  
However, indeed it is still necessary to avoid </script> being parsed as the 
end-tag of the “script” element:

<http://www.w3.org/TR/2012/CR-html5-20121217/scripting-1.html#restrictions-for-contents-of-script-elements>

That said, for backwards-compatibility it is certainly wise to escape “</” 
*always* within a “script” element.  Likewise for using 
“type="text/javascript"” on “script” elements and “type="text/css"” on 
“style” elements.

-- 
PointedEars

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Parallel Download Abstraction "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2013-05-29 17:09 -0700
  Re: Parallel Download Abstraction Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-05-30 03:01 +0200
    Re: Parallel Download Abstraction "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2013-05-29 19:17 -0700
      Re: Parallel Download Abstraction Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-05-30 05:13 +0200
        Re: Parallel Download Abstraction "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2013-05-30 17:56 -0700
          Re: Parallel Download Abstraction Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-05-31 14:59 +0200
            Re: Parallel Download Abstraction "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2013-06-01 03:18 -0700
              Re: Parallel Download Abstraction Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-06-01 15:10 +0200
                Re: Parallel Download Abstraction "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2013-06-01 18:21 -0700
                Re: Parallel Download Abstraction Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-06-03 14:50 +0200
                Re: Parallel Download Abstraction Stefan Weiss <krewecherl@gmail.com> - 2013-06-04 02:20 +0200
                Re: Parallel Download Abstraction Scott Sauyet <scott.sauyet@gmail.com> - 2013-06-03 18:04 -0700
                Re: Parallel Download Abstraction "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2013-06-03 20:01 -0700
              Re: Parallel Download Abstraction Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-06-01 15:15 +0200
                Re: Parallel Download Abstraction "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2013-06-01 18:05 -0700

csiph-web