Loading ...
Sorry, an error occurred while loading the content.

Re: [jslint] Re: body tag

Expand Messages
  • Andy Stevens
    ... Not always, I have inline scripts that work just fine so long as the parts of the DOM they are manipulating are ready & available. ... Seems reasonable to
    Message 1 of 5 , Aug 5 5:08 AM
    • 0 Attachment
      2008/8/5 Paul de Jong <riderpaul@...>:
      > The issue I was referring to is that the body tag needs to be
      > completely loaded before a DOM script runs,

      Not always, I have inline scripts that work just fine so long as the
      parts of the DOM they are manipulating are ready & available.

      > especially if you have
      > something like document.body.appendChild in your script.

      Seems reasonable to me that the body should be complete before you add to it.

      > Having the
      > script in the body means one needs to do complicated DOM checking to
      > make sure the body is loaded before the script runs...or at least set
      > a arbitrary delay in the hopes that the end of the body will get
      > processed in that time.

      How complicated is <body
      onload="finished_loading_so_call_the_script_now()"> anyway?

      > It seems weird to put the script tag inside the body tag, when
      > logically it should come after it. I was just wondering if there was
      > some reason other then the one you stated.
      >
      > I have never encountered a problem putting the script tag after the
      > body tag.

      Hey, if it works for you then go for it. So long as you don't care
      about your HTML being invalid according to the DTD, so it may break
      unexpectedly in future browser versions. If you care so much, you can
      also join the HTML 5 discussions and try to get it added to the spec.

      What does any of this have to do with JSLint, though? Are you saying
      that your inline script isn't being checked if it's not inside the
      head or body tags?


      Andy.
    • Paul de Jong
      The issue with onload is that it is not ondomload, so if any file being downloaded takes too long the script does not fire and the user could be interacting
      Message 2 of 5 , Aug 5 10:55 AM
      • 0 Attachment
        The issue with onload is that it is not ondomload, so if any file
        being downloaded takes too long the script does not fire and the user
        could be interacting even before the script loads.

        The two main reasons for me asking the question here are: 1) I just
        read "JavaScript: The Good Parts, Douglas Crockford, O'Reilly" and
        think it is the best JavaScript book I have ever read. It does avoid
        DOM issues entirely though, and I was hoping to get an informed
        opinion on this topic. I work on image heavy sites and onload is not
        an option. 2) I used JSLint and it told me that putting the script tag
        below the body was bad and I was wondering why. I was wondering if it
        was just a convention to put the script tag(s) in the head and body or
        if it was an actual rule.

        I will make a suggestion for the HTML 5 group. I think a footer block
        that was guaranteed to run just after the DOM is fully loaded would be
        great.

        Thank you for your responses!

        On Tue, Aug 5, 2008 at 5:08 AM, Andy Stevens
        <insomniacpenguin@...> wrote:
        > 2008/8/5 Paul de Jong <riderpaul@...>:
        >
        >> The issue I was referring to is that the body tag needs to be
        >> completely loaded before a DOM script runs,
        >
        > Not always, I have inline scripts that work just fine so long as the
        > parts of the DOM they are manipulating are ready & available.
        >
        >> especially if you have
        >> something like document.body.appendChild in your script.
        >
        > Seems reasonable to me that the body should be complete before you add to
        > it.
        >
        >> Having the
        >> script in the body means one needs to do complicated DOM checking to
        >> make sure the body is loaded before the script runs...or at least set
        >> a arbitrary delay in the hopes that the end of the body will get
        >> processed in that time.
        >
        > How complicated is <body
        > onload="finished_loading_so_call_the_script_now()"> anyway?
        >
        >> It seems weird to put the script tag inside the body tag, when
        >> logically it should come after it. I was just wondering if there was
        >> some reason other then the one you stated.
        >>
        >> I have never encountered a problem putting the script tag after the
        >> body tag.
        >
        > Hey, if it works for you then go for it. So long as you don't care
        > about your HTML being invalid according to the DTD, so it may break
        > unexpectedly in future browser versions. If you care so much, you can
        > also join the HTML 5 discussions and try to get it added to the spec.
        >
        > What does any of this have to do with JSLint, though? Are you saying
        > that your inline script isn't being checked if it's not inside the
        > head or body tags?
        >
        > Andy.
        >
        >
      Your message has been successfully submitted and would be delivered to recipients shortly.