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

JSLint and HTML

Expand Messages
  • douglascrockford
    When I began JSLint in 2001, the usual practice in web applications was to include inline scripts and event handlers in HTML. So JSLint includes an HTML parser
    Message 1 of 13 , Mar 15 3:01 PM
    • 0 Attachment
      When I began JSLint in 2001, the usual practice in web applications was to include inline scripts and event handlers in HTML. So JSLint includes an HTML parser so that it can locate and inspect the embedded scripts.

      Since then, we have determined that embedding JavaScript in an HTML file is a very bad practice. It is bad from a performance standpoint because gzip and caching are not possible. It is bad from a security standpoint because of the XSS hazard. CSP cannot be effective unless you strictly follow the good practice of segregating scripts.

      Since the purpose of JSLint is to promote good practice, I will be removing JSLint's HTML parser.
    • Mark Volkmann
      Hmm. I m not happy about that. I sometimes use JSLint to check HTML and CSS files. It seems to do a good job at both. ... -- R. Mark Volkmann Object Computing,
      Message 2 of 13 , Mar 15 3:15 PM
      • 0 Attachment
        Hmm. I'm not happy about that. I sometimes use JSLint to check HTML and CSS
        files. It seems to do a good job at both.

        On Fri, Mar 15, 2013 at 5:01 PM, douglascrockford <douglas@...>wrote:

        > **
        >
        >
        > When I began JSLint in 2001, the usual practice in web applications was to
        > include inline scripts and event handlers in HTML. So JSLint includes an
        > HTML parser so that it can locate and inspect the embedded scripts.
        >
        > Since then, we have determined that embedding JavaScript in an HTML file
        > is a very bad practice. It is bad from a performance standpoint because
        > gzip and caching are not possible. It is bad from a security standpoint
        > because of the XSS hazard. CSP cannot be effective unless you strictly
        > follow the good practice of segregating scripts.
        >
        > Since the purpose of JSLint is to promote good practice, I will be
        > removing JSLint's HTML parser.
        >
        >
        >



        --
        R. Mark Volkmann
        Object Computing, Inc.


        [Non-text portions of this message have been removed]
      • Dylon Edwards
        That sounds good to me! Thanks for maintaining JSlint, you do a great job. ... [Non-text portions of this message have been removed]
        Message 3 of 13 , Mar 15 3:51 PM
        • 0 Attachment
          That sounds good to me! Thanks for maintaining JSlint, you do a great job.
          On Mar 15, 2013 3:01 PM, "douglascrockford" <douglas@...> wrote:

          > **
          >
          >
          > When I began JSLint in 2001, the usual practice in web applications was to
          > include inline scripts and event handlers in HTML. So JSLint includes an
          > HTML parser so that it can locate and inspect the embedded scripts.
          >
          > Since then, we have determined that embedding JavaScript in an HTML file
          > is a very bad practice. It is bad from a performance standpoint because
          > gzip and caching are not possible. It is bad from a security standpoint
          > because of the XSS hazard. CSP cannot be effective unless you strictly
          > follow the good practice of segregating scripts.
          >
          > Since the purpose of JSLint is to promote good practice, I will be
          > removing JSLint's HTML parser.
          >
          >
          >


          [Non-text portions of this message have been removed]
        • benquarmby
          Does this mean anything for the CSS parser? Any plans to refine JSLint down to JavaScript / JSON only?
          Message 4 of 13 , Mar 16 7:14 AM
          • 0 Attachment
            Does this mean anything for the CSS parser?

            Any plans to refine JSLint down to JavaScript / JSON only?

            --- In jslint_com@yahoogroups.com, "douglascrockford" <douglas@...> wrote:
            >
            > When I began JSLint in 2001, the usual practice in web applications was to include inline scripts and event handlers in HTML. So JSLint includes an HTML parser so that it can locate and inspect the embedded scripts.
            >
            > Since then, we have determined that embedding JavaScript in an HTML file is a very bad practice. It is bad from a performance standpoint because gzip and caching are not possible. It is bad from a security standpoint because of the XSS hazard. CSP cannot be effective unless you strictly follow the good practice of segregating scripts.
            >
            > Since the purpose of JSLint is to promote good practice, I will be removing JSLint's HTML parser.
            >
          • Lindsay John Lawrence
            I am currently getting the following error in JSLint and don t understand why. ... Bad for in variable header . ... I am iterating over object {} properties
            Message 5 of 13 , Mar 19 4:11 PM
            • 0 Attachment
              I am currently getting the following error in JSLint and don't understand why.
              -----------------------------------------------------------------------
              Bad for in variable 'header'.
              -----------------------------------------------------------------------

              I am iterating over object {} properties (not an array), am using hasOwnPropery() and both header and headers are declared in the relevant scope.

              Can someone tell me why? I read through the '

              Sample Code:

                      var header;
                      var headers = {...};  
              for (header in headers) {
                   if (headers.hasOwnProperty(header)) {
                       .....
                   }
              }


              [Non-text portions of this message have been removed]
            • douglascrockford
              ... It works for me.
              Message 6 of 13 , Mar 19 4:53 PM
              • 0 Attachment
                --- In jslint_com@yahoogroups.com, Lindsay John Lawrence <thinknlive@...> wrote:
                >
                > I am currently getting the following error in JSLint and don't understand why.
                > -----------------------------------------------------------------------
                > Bad for in variable 'header'.
                > -----------------------------------------------------------------------
                >
                > I am iterating over object {} properties (not an array), am using hasOwnPropery() and both header and headers are declared in the relevant scope.
                >
                > Can someone tell me why? I read through the '
                >
                > Sample Code:
                >
                >         var header;
                >         var headers = {...};  
                > for (header in headers) {
                >      if (headers.hasOwnProperty(header)) {
                >          .....
                >      }
                > }


                It works for me.
              • Lindsay John Lawrence
                I am sorry about that. I needed another pair of eyes.... On further inspection... the actual code was something like: /*global doDoh */ (function doh (headers)
                Message 7 of 13 , Mar 19 5:41 PM
                • 0 Attachment
                  I am sorry about that. I needed another pair of eyes....

                  On further inspection... the actual code was something like:

                  /*global doDoh */
                  (function doh (headers)  {
                    "use strict";
                    var header; 
                    var noop = function () {};
                    doDoh (function () {
                      for (header in headers) {

                         if (headers.hasOwnProperty(header)) {
                              noop(); 
                            }
                          }  
                      });
                  }());


                  So, while it ran, it failed jslint due to where I had 'header' declared.  I like my code to pass jslint. In this case I was momentarily blind to the inner function.

                  Thank you.



                  ________________________________
                  From: douglascrockford <douglas@...>
                  To: jslint_com@yahoogroups.com
                  Sent: Tuesday, March 19, 2013 4:53 PM
                  Subject: [jslint] Re: jslint error: "Bad for in variable 'header'.?


                   
                  --- In jslint_com@yahoogroups.com, Lindsay John Lawrence <thinknlive@...> wrote:
                  >
                  > I am currently getting the following error in JSLint and don't understand why.
                  > ----------------------------------------------------------
                  > Bad for in variable 'header'.
                  > ----------------------------------------------------------
                  >
                  > I am iterating over object {} properties (not an array), am using hasOwnPropery() and both header and headers are declared in the relevant scope.
                  >
                  > Can someone tell me why? I read through the '
                  >
                  > Sample Code:
                  >
                  >         var header;
                  >         var headers = {...};  
                  > for (header in headers) {
                  >      if (headers.hasOwnProperty(header)) {
                  >          .....
                  >      }
                  > }

                  It works for me.




                  [Non-text portions of this message have been removed]
                • hemanrobinson
                  For our project, embedding JavaScript in HTML is not bad practice. In fact, there is no alternative. We are required to produce a single output file. The
                  Message 8 of 13 , Mar 21 8:37 AM
                  • 0 Attachment
                    For our project, embedding JavaScript in HTML is not bad practice. In fact, there is no alternative. We are required to produce a single output file.

                    The reason is, our customers email these files, and post them to their corporate intranets. Our customers are not stupid, but neither do they want the hassle of managing multiple files, or arguing with their IT folks about how those files should be deployed.

                    We have been delighted with JSLint for several years. Please give us an option to retain this feature. Thanks!


                    --- In jslint_com@yahoogroups.com, "douglascrockford" <douglas@...> wrote:
                    >
                    > When I began JSLint in 2001, the usual practice in web applications was to include inline scripts and event handlers in HTML. So JSLint includes an HTML parser so that it can locate and inspect the embedded scripts.
                    >
                    > Since then, we have determined that embedding JavaScript in an HTML file is a very bad practice. It is bad from a performance standpoint because gzip and caching are not possible. It is bad from a security standpoint because of the XSS hazard. CSP cannot be effective unless you strictly follow the good practice of segregating scripts.
                    >
                    > Since the purpose of JSLint is to promote good practice, I will be removing JSLint's HTML parser.
                    >
                  • IcedNet Development Team
                    So a single zip with 3 files (html, css, js) is out of the question? How do they deal with images? Text only? Wow, I have some flaky clients, but that is def
                    Message 9 of 13 , Mar 21 8:54 AM
                    • 0 Attachment
                      So a single zip with 3 files (html, css, js) is out of the question? How do they deal with images? Text only?
                      Wow, I have some flaky clients, but that is def in the top 5... :D
                      Good luck.

                      Peace,
                      Dan

                      On 2013/03 /21, at 11:37 AM, hemanrobinson wrote:

                      > For our project, embedding JavaScript in HTML is not bad practice. In fact, there is no alternative. We are required to produce a single output file.
                      >
                      > The reason is, our customers email these files, and post them to their corporate intranets. Our customers are not stupid, but neither do they want the hassle of managing multiple files, or arguing with their IT folks about how those files should be deployed.
                      >
                      > We have been delighted with JSLint for several years. Please give us an option to retain this feature. Thanks!
                      >
                      > --- In jslint_com@yahoogroups.com, "douglascrockford" <douglas@...> wrote:
                      > >
                      > > When I began JSLint in 2001, the usual practice in web applications was to include inline scripts and event handlers in HTML. So JSLint includes an HTML parser so that it can locate and inspect the embedded scripts.
                      > >
                      > > Since then, we have determined that embedding JavaScript in an HTML file is a very bad practice. It is bad from a performance standpoint because gzip and caching are not possible. It is bad from a security standpoint because of the XSS hazard. CSP cannot be effective unless you strictly follow the good practice of segregating scripts.
                      > >
                      > > Since the purpose of JSLint is to promote good practice, I will be removing JSLint's HTML parser.
                      > >
                      >
                      >



                      [Non-text portions of this message have been removed]
                    • Felix E. Klee
                      On Thu, Mar 21, 2013 at 3:37 PM, hemanrobinson ... Good practice is to use separate files during development, and then
                      Message 10 of 13 , Mar 21 9:46 AM
                      • 0 Attachment
                        On Thu, Mar 21, 2013 at 3:37 PM, hemanrobinson <hemanrobinson@...>
                        wrote:
                        > For our project, embedding JavaScript in HTML is not bad practice. In
                        > fact, there is no alternative. We are required to produce a single
                        > output file.

                        Good practice is to use separate files during development, and then
                        (automatically) merge them together for deployment.
                      • falk.werner@rocketmail.com
                        ... Is it good practice to only check parts of a product and not the assembled product ( a single output file ) itself?
                        Message 11 of 13 , Mar 21 11:14 PM
                        • 0 Attachment
                          > Good practice is to use separate files during development, and then
                          > (automatically) merge them together for deployment.

                          Is it good practice to only check parts of a product and not the assembled product ("a single output file") itself?
                        • Andrew Todd
                          ... You will be better off moving to a build and templating system that pulls in your JavaScript source files and your HTML templates, checks them separately,
                          Message 12 of 13 , Mar 22 10:09 AM
                          • 0 Attachment
                            On Thu, Mar 21, 2013 at 11:37 AM, hemanrobinson <hemanrobinson@...>wrote:

                            > **
                            > For our project, embedding JavaScript in HTML is not bad practice. In
                            > fact, there is no alternative. We are required to produce a single output
                            > file.
                            >

                            You will be better off moving to a build and templating system that pulls
                            in your JavaScript source files and your HTML templates, checks them
                            separately, does any minifying you want, and then combines them together.
                            In this way, you are using tools designed for their tasks.

                            I use Maven, the JSLint Maven plugin, and the Freemarker preprocessor Maven
                            plugin for this purpose.


                            [Non-text portions of this message have been removed]
                          • hemanrobinson
                            Thanks for all the advice. We have found a workaround. I am sorry to lose the HTML parsing; it was a useful feature.
                            Message 13 of 13 , Mar 25 11:13 AM
                            • 0 Attachment
                              Thanks for all the advice. We have found a workaround.

                              I am sorry to lose the HTML parsing; it was a useful feature.


                              --- In jslint_com@yahoogroups.com, Andrew Todd <andrew.todd659@...> wrote:
                              >
                              > On Thu, Mar 21, 2013 at 11:37 AM, hemanrobinson <hemanrobinson@...>wrote:
                              >
                              > > **
                              > > For our project, embedding JavaScript in HTML is not bad practice. In
                              > > fact, there is no alternative. We are required to produce a single output
                              > > file.
                              > >
                              >
                              > You will be better off moving to a build and templating system that pulls
                              > in your JavaScript source files and your HTML templates, checks them
                              > separately, does any minifying you want, and then combines them together.
                              > In this way, you are using tools designed for their tasks.
                              >
                              > I use Maven, the JSLint Maven plugin, and the Freemarker preprocessor Maven
                              > plugin for this purpose.
                              >
                              >
                              > [Non-text portions of this message have been removed]
                              >
                            Your message has been successfully submitted and would be delivered to recipients shortly.