Avoiding bad <SCRIPT SRC=> hanging the page

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Pascal Damian

    Avoiding bad <SCRIPT SRC=> hanging the page

    My HTML pages have a <SCRIPT SRC=http://remote/script> at the top'ish
    of each page. Sometimes the remote host (probably due to heavy load or
    flaky network connectivity) doesn't respond for a long time. This
    causes the whole page to appear hanging without anything loading.

    Is there some trick I can use with settimeout() so that if the remote
    script cannot be loaded after, say, 30 seconds, then I can tell the
    page/browser to cancel loading that script?

    --
    Pascal Damian
  • Martin Honnen

    #2
    Re: Avoiding bad &lt;SCRIPT SRC=&gt; hanging the page



    Pascal Damian wrote:
    [color=blue]
    > My HTML pages have a <SCRIPT SRC=http://remote/script> at the top'ish
    > of each page. Sometimes the remote host (probably due to heavy load or
    > flaky network connectivity) doesn't respond for a long time. This
    > causes the whole page to appear hanging without anything loading.
    >
    > Is there some trick I can use with settimeout() so that if the remote
    > script cannot be loaded after, say, 30 seconds, then I can tell the
    > page/browser to cancel loading that script?[/color]

    For IE if the script doesn't generate page content (e.g. doesn't use
    document.write) try
    <script defer type="text/javascript"
    src="http://example.com/file.js"></script>

    --

    Martin Honnen


    Comment

    • Lasse Reichstein Nielsen

      #3
      Re: Avoiding bad &lt;SCRIPT SRC=&gt; hanging the page

      Martin Honnen <mahotrash@yaho o.de> writes:
      [color=blue]
      > For IE if the script doesn't generate page content (e.g. doesn't use
      > document.write) try
      > <script defer type="text/javascript"
      > src="http://example.com/file.js"></script>[/color]

      Not just IE. The "defer" attribute is specified in HTML 4.

      /L
      --
      Lasse Reichstein Nielsen - lrn@hotpop.com
      DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
      'Faith without judgement merely degrades the spirit divine.'

      Comment

      • Pascal Damian

        #4
        Re: Avoiding bad &lt;SCRIPT SRC=&gt; hanging the page

        Martin Honnen <mahotrash@yaho o.de> wrote in message news:<41190062@ olaf.komtel.net >...[color=blue]
        > Pascal Damian wrote:
        >[color=green]
        > > My HTML pages have a <SCRIPT SRC=http://remote/script> at the top'ish
        > > of each page. Sometimes the remote host (probably due to heavy load or
        > > flaky network connectivity) doesn't respond for a long time. This
        > > causes the whole page to appear hanging without anything loading.
        > >
        > > Is there some trick I can use with settimeout() so that if the remote
        > > script cannot be loaded after, say, 30 seconds, then I can tell the
        > > page/browser to cancel loading that script?[/color]
        >
        > For IE if the script doesn't generate page content (e.g. doesn't use
        > document.write) try
        > <script defer type="text/javascript"
        > src="http://example.com/file.js"></script>[/color]

        Sadly, the script does document.write( ...) (as I guess most other
        interesting scripts do).

        Is there a way I can do something like this:

        <script>
        if (can't ping/connect to port 80 of remote-host in 15 seconds) {
        // skip
        } else {
        document.write( '<script src=http://remote-host/script></script>');
        }
        }
        </script>

        --
        Pascal Damian

        Comment

        • Martin Honnen

          #5
          Re: Avoiding bad &lt;SCRIPT SRC=&gt; hanging the page



          Lasse Reichstein Nielsen wrote:
          [color=blue]
          > Martin Honnen <mahotrash@yaho o.de> writes:
          >
          >[color=green]
          >>For IE if the script doesn't generate page content (e.g. doesn't use
          >>document.writ e) try
          >> <script defer type="text/javascript"
          >> src="http://example.com/file.js"></script>[/color]
          >
          >
          > Not just IE. The "defer" attribute is specified in HTML 4.[/color]

          But Mozilla ignores it for instance so that is why I labelled that
          solution as working with IE where I know it to work.
          What are your experiences with Opera 7, does it take the defer attribute
          into account?

          --

          Martin Honnen


          Comment

          • Martin Honnen

            #6
            Re: Avoiding bad &lt;SCRIPT SRC=&gt; hanging the page



            Pascal Damian wrote:

            [color=blue]
            > Is there a way I can do something like this:
            >
            > <script>
            > if (can't ping/connect to port 80 of remote-host in 15 seconds) {
            > // skip
            > } else {
            > document.write( '<script src=http://remote-host/script></script>');
            > }
            > }
            > </script>[/color]

            No, certainly not with client-side script, there might be browsers
            allowing their users to specify when to to abort a connection attempt
            but script doesn't allow for that.

            There are some browsers that would allow you to make a HTTP HEAD request
            with scripting but you can't specify a timout limit for that either




            --

            Martin Honnen


            Comment

            • Harag

              #7
              Re: Avoiding bad &lt;SCRIPT SRC=&gt; hanging the page

              On 11 Aug 2004 00:27:30 -0700, pascaldamian@ic qmail.com (Pascal
              Damian) wrote:
              [color=blue]
              >Martin Honnen <mahotrash@yaho o.de> wrote in message news:<41190062@ olaf.komtel.net >...[color=green]
              >> Pascal Damian wrote:
              >>[color=darkred]
              >> > My HTML pages have a <SCRIPT SRC=http://remote/script> at the top'ish
              >> > of each page. Sometimes the remote host (probably due to heavy load or
              >> > flaky network connectivity) doesn't respond for a long time. This
              >> > causes the whole page to appear hanging without anything loading.
              >> >
              >> > Is there some trick I can use with settimeout() so that if the remote
              >> > script cannot be loaded after, say, 30 seconds, then I can tell the
              >> > page/browser to cancel loading that script?[/color]
              >>
              >> For IE if the script doesn't generate page content (e.g. doesn't use
              >> document.write) try
              >> <script defer type="text/javascript"
              >> src="http://example.com/file.js"></script>[/color]
              >
              >Sadly, the script does document.write( ...) (as I guess most other
              >interesting scripts do).
              >
              >Is there a way I can do something like this:
              >
              ><script>
              > if (can't ping/connect to port 80 of remote-host in 15 seconds) {
              > // skip
              > } else {
              > document.write( '<script src=http://remote-host/script></script>');
              > }
              >}
              ></script>[/color]


              Why not ask the remote host for their permission to use the script
              then take a copy of it and use it from your own server?

              Al.

              Comment

              • Martin Honnen

                #8
                Re: Avoiding bad &lt;SCRIPT SRC=&gt; hanging the page



                Martin Honnen wrote:

                [color=blue]
                > Lasse Reichstein Nielsen wrote:
                >[color=green]
                >> Martin Honnen <mahotrash@yaho o.de> writes:
                >>
                >>[color=darkred]
                >>> For IE if the script doesn't generate page content (e.g. doesn't use
                >>> document.write) try
                >>> <script defer type="text/javascript"
                >>> src="http://example.com/file.js"></script>[/color]
                >>
                >>
                >>
                >> Not just IE. The "defer" attribute is specified in HTML 4.[/color]
                >
                >
                > But Mozilla ignores it for instance so that is why I labelled that
                > solution as working with IE where I know it to work.
                > What are your experiences with Opera 7, does it take the defer attribute
                > into account?[/color]

                I just tested with Opera 7.50 and it seems to ignore the defer attribute
                the same way Mozilla does.

                --

                Martin Honnen


                Comment

                • Martin Honnen

                  #9
                  Re: Avoiding bad &lt;SCRIPT SRC=&gt; hanging the page



                  Martin Honnen wrote:

                  [color=blue]
                  > I just tested with Opera 7.50 and it seems to ignore the defer attribute
                  > the same way Mozilla does.[/color]

                  This is the test case:


                  --

                  Martin Honnen


                  Comment

                  • Kien

                    #10
                    Re: Avoiding bad &lt;SCRIPT SRC=&gt; hanging the page

                    Hi,

                    I think you're trying to remove the ads on your free web pages.
                    It's difficult.
                    Buy your own site and get full control of your pages.

                    Kien

                    pascaldamian@ic qmail.com (Pascal Damian) wrote in message news:<6bd4a4d3. 0408100858.afe6 ffb@posting.goo gle.com>...[color=blue]
                    > My HTML pages have a <SCRIPT SRC=http://remote/script> at the top'ish
                    > of each page. Sometimes the remote host (probably due to heavy load or
                    > flaky network connectivity) doesn't respond for a long time. This
                    > causes the whole page to appear hanging without anything loading.
                    >
                    > Is there some trick I can use with settimeout() so that if the remote
                    > script cannot be loaded after, say, 30 seconds, then I can tell the
                    > page/browser to cancel loading that script?[/color]

                    Comment

                    • Thomas 'PointedEars' Lahn

                      #11
                      Re: Avoiding bad &lt;SCRIPT SRC=&gt; hanging the page

                      Kien wrote:
                      [color=blue]
                      > I think you're trying to remove the ads on your free web pages.
                      > It's difficult.[/color]

                      It's illegal.


                      PointedEars

                      Comment

                      • Randy Webb

                        #12
                        Re: Avoiding bad &lt;SCRIPT SRC=&gt; hanging the page

                        Thomas 'PointedEars' Lahn wrote:[color=blue]
                        > Kien wrote:
                        >
                        >[color=green]
                        >>I think you're trying to remove the ads on your free web pages.
                        >>It's difficult.[/color]
                        >
                        >
                        > It's illegal.[/color]

                        No its not.

                        --
                        Randy
                        comp.lang.javas cript FAQ - http://jibbering.com/faq

                        Comment

                        • Pascal Damian

                          #13
                          Re: Avoiding bad &lt;SCRIPT SRC=&gt; hanging the page

                          Nope, wrong guess. :-) I'm trying to _keep_ the ads on my pages (which
                          is hosted at a cost which I pay for, thank you very much).

                          The problem is, the ad network is rather flaky, sometimes they're
                          having network difficulty. So when that happens, my visitors are
                          stuck. The pages can't load.

                          Someone will soon say, "why don't you just switch to another ad
                          network?". Which of course is not a wrong suggestion, but irrelevant
                          to my original question.

                          --
                          Pascal Damian

                          caoxuankien@hot mail.com (Kien) wrote in message news:<166d5d19. 0408111337.44b4 4cb6@posting.go ogle.com>...[color=blue]
                          > Hi,
                          >
                          > I think you're trying to remove the ads on your free web pages.
                          > It's difficult.
                          > Buy your own site and get full control of your pages.
                          >
                          > Kien
                          >
                          > pascaldamian@ic qmail.com (Pascal Damian) wrote in message news:<6bd4a4d3. 0408100858.afe6 ffb@posting.goo gle.com>...[color=green]
                          > > My HTML pages have a <SCRIPT SRC=http://remote/script> at the top'ish
                          > > of each page. Sometimes the remote host (probably due to heavy load or
                          > > flaky network connectivity) doesn't respond for a long time. This
                          > > causes the whole page to appear hanging without anything loading.
                          > >
                          > > Is there some trick I can use with settimeout() so that if the remote
                          > > script cannot be loaded after, say, 30 seconds, then I can tell the
                          > > page/browser to cancel loading that script?[/color][/color]

                          Comment

                          • Michael Winter

                            #14
                            Re: Avoiding bad &lt;SCRIPT SRC=&gt; hanging the page

                            On Wed, 11 Aug 2004 22:24:58 -0400, Randy Webb <HikksNotAtHome @aol.com>
                            wrote:
                            [color=blue]
                            > Thomas 'PointedEars' Lahn wrote:
                            >[color=green]
                            >> Kien wrote:
                            >>[color=darkred]
                            >>> I think you're trying to remove the ads on your free web pages.
                            >>> It's difficult.[/color]
                            >>
                            >> It's illegal.[/color]
                            >
                            > No its not.[/color]

                            Illegal is the wrong word, but it is forbidden in virtually every single
                            case[1] and liable to result in the termination of your service (if
                            discovered).

                            Mike


                            [1] I say "virtually" because there's bound to be a host somewhere that
                            neglected to add a "don't remove our banners/pop-ups" clause into the
                            Terms and Conditions agreement.

                            --
                            Michael Winter
                            Replace ".invalid" with ".uk" to reply by e-mail

                            Comment

                            • Randy Webb

                              #15
                              Re: Avoiding bad &lt;SCRIPT SRC=&gt; hanging the page

                              Michael Winter wrote:[color=blue]
                              > On Wed, 11 Aug 2004 22:24:58 -0400, Randy Webb <HikksNotAtHome @aol.com>
                              > wrote:
                              >[color=green]
                              >> Thomas 'PointedEars' Lahn wrote:
                              >>[color=darkred]
                              >>> Kien wrote:
                              >>>
                              >>>> I think you're trying to remove the ads on your free web pages.
                              >>>> It's difficult.
                              >>>
                              >>>
                              >>> It's illegal.[/color]
                              >>
                              >>
                              >> No its not.[/color]
                              >
                              >
                              > Illegal is the wrong word, but it is forbidden in virtually every
                              > single case[1] and liable to result in the termination of your service
                              > (if discovered).[/color]

                              Correct. Doesn't make it illegal, makes it a violation of the terms of
                              service. Pointed Head seems to be on a diatribe of late about the use of
                              particular words. If he wants to point fingers about the use of words,
                              he should take more care in his choice of words himself. YKWIM?


                              --
                              Randy
                              comp.lang.javas cript FAQ - http://jibbering.com/faq

                              Comment

                              Working...