Help Jquery: unable to register a ready function

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • David Mark

    #46
    Re: Help Jquery: unable to register a ready function

    On Nov 5, 12:07 pm, "Richard Cornford" <Rich...@litote s.demon.co.uk>
    wrote:
    On Oct 29, 10:14 pm, Conrad Lender wrote:
    >
    On 2008-10-29 20:43, David Mark wrote:
    >>
    That one is my personal favorite [..]
    >
    Actually, I thought it was quite interesting.
    >
    I found it quite informative, but on its author rather than its subject.
    >
    He wrote that scripting libraries like JQuery or Dojo are
    used, among other things, to "pave over" browser bugs and
    incompatibiliti es,
    >
    'Plaster over' rather than "pave over". In solving a small subset of the
    Exactly. Their unit tests throw an exception and somebody comes up
    with a half-baked plan to patch it with yet another browser sniff.
    Prototype looks like a structure ready to collapse as so many hacks
    have been piled on top of other hacks. They are reduced to testing
    minor version numbers at one point. Of course, nobody seems to use
    Prototype anymore (other than with those Rails "helper" things.)
    jQuery has been widely mistaken as a viable alternative.

    [snip]
    | example:
    |
    | if ( elem.getAttribu te ) {
    |     // will die in Internet Explorer
    | }
    | That line will cause problems as Internet Explorer attempts to
    | execute the getAttribute function with no arguments (which is
    | invalid). (The obvious solution is to use
    | "typeof elem.getAttribu te == 'undefined'" instead.)
    >
    Now I know that that is pure BS because I have been using tests along
    You are correct. Pure and unadulterated BS and demonstrably so.
    the lines of - if(elem.getAttr ibute){ .... } - on Element nodes for
    years (at least 5) and have never seen them fail, and I do test/use that
    IIRC, it happens only with XML elements (appears they are ActiveX
    objects under the hood.) No surprise that jQuery attempts to deal
    with such objects. Clearly Resig bumped into my "unknown" bug and
    typical jumped to the wrong conclusion, based on guesswork,
    meditation, etc.
    code in (lots of versions of) IE. But still, lets make it easy for
    everyone to test the proposition for themselves and so verify its
    veracity. A simple test page might be:-
    >
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
      Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
        <head>
            <title></title>
    <script type="text/javascript">
    window.onload = function(){
        if(document.bod y.getAttribute) {
            alert(
                'document.body. getAttribute = '+
                document.body.g etAttribute
            );
        }};
    >
    </script>
        </head>
        <body>
        </body>
    </html>
    >
    Here is a slightly modified demonstration that shows how another
    property can explode in similar fashion (and how simple it is to test
    this case.) This property isn't even a method, so it proves that
    Resig's theory about accidentally calling methods by type conversion
    is nonsense.

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
    Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title></title>
    <script type="text/javascript">
    window.onload = function(){
    var el = document.create Element('div');
    document.body.a ppendChild(el);

    document.body.i nnerHTML = '';

    if(typeof el.offsetParent == 'unknown'){
    alert('Warning. About to explode...');
    }
    alert('offsetPa rent = '+ el.offsetParent );
    };

    </script>
    </head>
    <body>

    </body>
    </html>

    Clearly a competently designed and written Web application will never
    run into this. However, since MS can change the rules at any time, I
    advocate using the typeof operator to test all host object methods.
    Now to start with we need to know what IE's - getAttribute - would do if
    it were executed with no arguments. The DOM spec is not that clear,
    execute that it says no exceptions will be thrown. It is easy enough to
    test, and it turns out that:-
    >
    alert(''+docume nt.body.getAttr ibute());
    >
    - alert "null", so the method call returns null. So, if -
    elem.getAttribu te - calls the method with no arguments the result is
    likely be null. If the result is null then in the above test page the -
    if(document.bod y.getAttribute) { -  test will be false, the - if - branch
    will not be entered and the alert will not be shown. But on every IE
    version where I have tried the above test the alert is shown, plus the
    alert shows "document.body. getAttribute = function
    getAttribute(){[native code]}", not the "null" that would be result of
    calling the method with no arguments.
    Clearly Resig prefers voodoo to scientific methods (like testing) or
    he would never have published his article.
    >
    Can you find an IE version that does exhibit this 'issue'? I am pretty
    certain that I have tested code that used this test on IE versions from
    4 to 8 without issue, so I doubt it.
    Not the issue as such (clearly it is being mistaken for another
    issue.)
    >
    Given that this assertion is demonstrably BS may attitude toward the
    previous "demonstrat ed" issue on Safari, in light of my test, leans
    heavily toward dismissing that as also being BS.
    My feeling exactly. I have never finished that article. It is
    sickening to think how many people have visited this Fantasyland over
    the years and gone on to spread such "wisdom" in the real world. If
    there is one guy in the world who should not be talking about feature
    testing, it is this guy. Ironic that he is near constantly blithering
    about the subject.
    >
    So what is this article? If it is a reasoned analysis of future
    A delusion masquerading as a reasoned argument. As you mentioned, the
    argument serves only to justify his own incompetence vis-a-vis feature
    detection. One of the Prototype twits authored a similar call to
    browser sniffing back when that library was the flavor of the day.
    People have a right to their own ignorant opinions, but what compels
    these people to spread them like they are gospel?

    [snip]
    >
    One more quote from Resig's article:-
    >
    | The point of these examples isn't to rag on Safari or Internet
    Explorer
    | in particular, but to point out that rendering-engine checks can end
    up
    | becoming very convoluted - and thusly, more vulnerable to future
    | changes within a browser.
    And thus, John Resig is both incompetent and incoherent.
    >
    - which can be summarised as 'complexity equals vulnerability'.
    Interesting take.
    Certainly complexity will relate to vulnerability, in a very general
    sense, but in the context of feature detection if a test is the correct
    test, no matter how complex it may be, it will not be vulnerable to
    updates in the browsers because significant changes the browsers will
    directly impact on the outcomes of those tests, which is the point of
    feature detection.
    >
    From my own experience; when IE 7 was released I was working on a web
    application with (at the time) 100,000 lines of client-side code (code
    employing nothing but feature detection where it is necessary to react
    to divergent environments). The total number of changes in the scripts
    needed to accommodate IE 7 was zero. When Chrome was released the total
    number of changes necessary to accommodate that was also zero. And last
    week QA started testing that application on IE 8. They may take another
    week to run through all there tests but so far they have found no
    issues, and I have a realistic expectation that they will not (as pretty
    much everything that would be likely to be problematic would inevitably
    get used in the first day or so).
    Yes. My experiences with Chrome, Windows Safari, FF3, Opera, etc.
    have been similar. Do things right the first time and you don't have
    to re-do them.
    >
    Now that is "Future Proof" javascript, and low maintenance javascript.
    The title of that article is ironic indeed. Even worse, jQuery's two
    main selling points are reduced maintenance and that it is "fast." We
    know browser sniffing only creates future maintenance headaches and,
    of course, there is no slower way to do anything in browser scripting
    than to use jQuery (the design ensures that.) He can rewrite his
    silly CSS selector queries until the end of the earth but it won't put
    a dent in the overall inefficiency (he is looking at a total rewrite
    from scratch to accomplish that.)
    >
    In those cases, feature tests can help; for the remaining
    cases they have no option but to go by browser version.
    >
    <snip>
    >
    Chrome and JQuery made interesting point about User Agent string based
    browser detection; Chrome works (more or less) with JQuery because its
    authors pragmatically gave it a UA string that would result in most
    current browser sniffing scripts identifying it as Safari, and treating
    Chrome as Safari is probably the best thing to do if you are going to
    script in that style at all. But this means that UA sting based browser
    sniffing was effective in this case not because it enabled the accurate
    determination of the browser and its version, but instead was effective
    precisely because it misidentified the browser and its version.
    Of course. And the purveyors of jQuery, Prototype, etc. ran their
    unit tests through it and rejoiced that their code still "worked."
    Somehow they see the coincidental circumstances that led to this
    latest "success" as validation of their baseless methods. People like
    that should not be writing software. Period. They certainly should
    not be degrading Web documents with their collective delusions.
    >
    Though for comic relief, you can't beat this one:
    >>
    What kind of idiot would delegate the most critical
    browser scripting tasks to people like that?
    >
    I thought it was funny. He found a weird behavior in IE,
    and joked about finding a use for it. You didn't take
    that seriously, did you?
    >
    I think you have missed the point. He observed a weird behaviour in IE,
    He did.
    applied an obviously fatly process to the analysis of that behaviour and
    that then resulted in his coming to a series of utterly false
    conclusions about what the observed behaviour was. Joking about
    applications for that behaviour became irrelevant as having
    misidentified the behaviour in the first place any proposed applications
    of that misidentified behaviour would be worthless even if taken
    seriously.
    >
    And you are likely to ask; his mistake was using an - alert - in the
    test. Generally, alerts aren't much use in examining pointing device
    interactions in web browsers because they tend to block script execution
    (and so real-time event handling) and they can shift focus (keyboard
    'enter' goes to the button on the box. Most people learn this lesson
    quite early on as they learn browser scripting, as a consequence of
    trying things out for themselves and trying to examine how they work.
    The BS examples on the 'future proof javascript' page might suggest that
    John Resig is not someone who goes in for trying things out for himself
    that often.
    Or paying the slightest attention to anything critical of his work.
    His mantra seems to be "stop hating me!" Last time I pointed out an
    obvious mistake to him, he responded with the age-old "argument" of
    library authors: "where is your way-cool cross-browser library?" Now
    that that "platform" has collapsed, he is predictably absent from all
    such discussions.
    >
    Here is an alternative test page for the IE setTimeout quirk:-
    >
    [snip]
    >
    While you may conclude that the reaction to the self proclaimed
    "JavaScript Ninja" on this group is biased and personal, in reality it
    And who on earth would take technical advice from a self-described
    "JavaScript Ninja?" I wonder if he has a JScript belt too?
    is mostly a direct reaction to what he writes/does, and a reaction
    informed by pertinent knowledge and experience in the field of browser
    scripting.
    I've had the displeasure of talking to him briefly (here) and came to
    the conclusion that he is a few sandwiches short of a picnic. But it
    is his code, books, blogs, etc. that irk me as he is spreading
    outrageous misconceptions.

    Comment

    • Conrad Lender

      #47
      Re: Help Jquery: unable to register a ready function

      Thanks for your thorough and interesting reply. I agree with much of
      what you wrote, so I'll focus on the direct questions.

      On 2008-11-05 18:07, Richard Cornford wrote:
      [e-commerce sites] Every time someone in that set is excluded from
      the group from whom money can be taken that is a direct result of a
      design decision. [..]
      So we come to trade-offs; is the increased turnover that will result from
      a more professional presentation greater than the loss in turnover that
      may result form designing out the possibility of the user of some
      browsers from accessing the site at all? How do you make those
      judgments, and who should be making those decisions, and based on what
      information, knowledge and experience?
      This boils down to the question which user agents an application is
      designed to support, and who makes that decision. Only the client is in
      a position to decide who to shut out, and he will (or should) base this
      decision on his customer base, collected browser statistics, and the
      advice of his technical staff and developers. Amazon will reach a
      different conclusion here than, say, YouTube, or a gaming site, or a
      portal for Ajax fans. Dropping support for ancient user agents can help
      keep the code base managable and reduce the maintainance effort. I would
      never say that JQuery is suitable for any site; but for some sites the
      target audience will be overwhelmingly likely to use one of the browser
      versions that JQuery supports.

      For personal sites, the owner gets to decide. A private blog, for
      example, would be much less affected by the reactions of the <1% of
      visitors whose user agent isn't in JQuery's list.

      Anyway, I wasn't trying to recommend or defend JQuery, I was only
      talking about the linked articles.
      >instead of hand-rolling yet another
      >cross-browser event abstraction layer, for example.
      >
      This, oft repeated, assertion that the only alternative to using a third
      party general purpose library is write everything from scratch for
      yourself is a total nonsense. In-between those two alternatives lay a
      whole spectrum of code re-use opportunities, and only the very
      masochistic are not re-using pre-written code for the bulk of their
      projects even if they are not using the 'popular' general purpose
      libraries.
      Perhaps so, but where *is* all that pre-written and tested code? Every
      time somebody asks for a good library (as in collection of code that
      helps to deal with browser quirks and incompatibiliti es), they're told
      that there is no such thing. If they dare to mention one of the popular
      libraries, they get flamed to cinders. If such a collection exists, I
      would very much like to know where to find it.
      "Demonstrat ed", did he? While there inevitably will be features that
      cannot be detected (though far fewer than may people would like to make
      out) I have to question whether John Resig demonstrated any of them in
      that article.
      (snipping your test cases) You're right. I had already tried to
      duplicate the problems mentioned by Resig and couldn't reproduce them
      either. Maybe the errors only happened with very obscure configurations,
      or maybe he's just wrong. Who knows. It doesn't really matter though,
      because the point was that object detection isn't a cure-all for
      cross-browser scripting, and I agree with that.
      Given that this assertion is demonstrably BS may attitude toward the
      previous "demonstrat ed" issue on Safari, in light of my test, leans
      heavily toward dismissing that as also being BS.
      Probably. Still, using bad (or let's be nice and say unreproducible)
      examples doesn't necessarily invalidate the main focus of the article,
      or at least the point that I found interesting - which is adding the
      JQuery test suite to the Mozilla test suite. It's *possible* that a new
      browser version could introduce bugs like the ones Resig used in his
      examples (even if they didn't exist now), or uncover bugs in the JQuery
      library. Testing a browser with a widely used library is a good thing.
      From my own experience; when IE 7 was released I was working on a web
      application with (at the time) 100,000 lines of client-side code (code
      employing nothing but feature detection where it is necessary to react
      to divergent environments). The total number of changes in the scripts
      needed to accommodate IE 7 was zero. When Chrome was released the total
      number of changes necessary to accommodate that was also zero. And last
      week QA started testing that application on IE 8. They may take another
      week to run through all there tests but so far they have found no
      issues, and I have a realistic expectation that they will not (as pretty
      much everything that would be likely to be problematic would inevitably
      get used in the first day or so).
      >
      Now that is "Future Proof" javascript, and low maintenance javascript.
      That's very impressive. In an application of that size, I'd expect to
      find issues even without accounting for new browsers. I assume that your
      requirements are vastly different from those who want to build a flashy
      site with moving objects and whistles and bells.
      Make use your IE status bar is visible and watch the
      displayed number as you click, mouse-down, move the mouse, release the
      mouse button. And when you have done that see what you think of Resig's
      conclusion that "What happened is positively bizarre: The callback
      function will be executed every time the user left clicks the mouse,
      anywhere in the document." In reality ckicking, and click events have
      nothing to with IE's behaviour, beyond their representing a mousedown
      followed by a mouseup.
      Looks like he was on the wrong track with his test, and you're the first
      person who's figured it out... (and the quirk looks even weirder now).
      I'm not about to defend his misjudgement, I just don't think he took it
      very seriously. He probably considers himself part of the "Web 2.0
      wave", whatever that is, so he tossed out a blog entry about a curious
      quirk without much research, to let the community figure it out and play
      with it. I really don't think this could or should be used to discredit
      him. What he does in his library is a different matter.


      As I said, I'm still convinced that checking browser types/versions
      can't always be avoided. But since both you and David say that it not
      only CAN be done, but HAS to be done, I'll try a little experiment and
      ask the group whenever I'm tempted to write [if browser is MSIE6]. If I
      can find solid cross-browser solutions for these problems, I'll gladly
      retract my statement.


      - Conrad

      Comment

      • David Mark

        #48
        Re: Help Jquery: unable to register a ready function

        On Nov 5, 3:29 pm, Conrad Lender <crlen...@yahoo .comwrote:
        Thanks for your thorough and interesting reply. I agree with much of
        what you wrote, so I'll focus on the direct questions.
        >
        On 2008-11-05 18:07, Richard Cornford wrote:
        >
        [e-commerce sites] Every time someone in that set is excluded from
        the group from whom money can be taken that is a direct result of a
        design decision. [..]
        So we come to trade-offs; is the increased turnover that will result from
        a more professional presentation greater than the loss in turnover that
        may result form designing out the possibility of the user of some
        browsers from accessing the site at all? How do you make those
        judgments, and who should be making those decisions, and based on what
        information, knowledge and experience?
        >
        This boils down to the question which user agents an application is
        designed to support, and who makes that decision. Only the client is in
        a position to decide who to shut out, and he will (or should) base this
        decision on his customer base, collected browser statistics, and the
        Browser statistics?! Are you kidding?
        advice of his technical staff and developers. Amazon will reach a
        different conclusion here than, say, YouTube, or a gaming site, or a
        They are both public Web sites. The idea that they should make a
        conscious decision to "shut out" users is absurd.
        portal for Ajax fans. Dropping support for ancient user agents can help
        As long as the documents are still usable in those ancient user
        agents, then that is fine. But you *cannot* degrade gracefully
        through browser sniffing. End of story.
        keep the code base managable and reduce the maintainance effort. I would
        The last thing that adding a browser sniffing script like jQuery to
        your app is going to do is save on maintenance. Scripts like that are
        patched to death, so trying to keep up with the ever-changing browser
        landscape is an exercise in futility. The more workarounds added to
        "fix" unit tests, the worse it gets. Try to remove any of these
        patches and the whole thing unravels. And you are going to delegate
        these tasks to people who do not understand the first thing about
        browser scripting? That is not a sound strategy.
        never say that JQuery is suitable for any site; but for some sites the
        target audience will be overwhelmingly likely to use one of the browser
        versions that JQuery supports.
        Absolute rubbish. And even on an Intranet where one configuration of
        IE is used, it is still a poorly designed, inefficient and ugly piece
        of code. Does that sound like something you want?
        >
        For personal sites, the owner gets to decide. A private blog, for
        example, would be much less affected by the reactions of the <1% of
        visitors whose user agent isn't in JQuery's list.
        But there are so many other options out there. What is the
        fascination with this crappy little script from three years ago?
        >
        Anyway, I wasn't trying to recommend or defend JQuery, I was only
        talking about the linked articles.
        Instead, you should have been reading the linked articles. If you
        didn't follow, then you should have searched the group for the links.
        All of this is re-hash.
        >
        instead of hand-rolling yet another
        cross-browser event abstraction layer, for example.
        >
        This, oft repeated, assertion that the only alternative to using a third
        party general purpose library is write everything from scratch for
        yourself is a total nonsense. In-between those two alternatives lay a
        whole spectrum of code re-use opportunities, and only the very
        masochistic are not re-using pre-written code for the bulk of their
        projects even if they are not using the 'popular' general purpose
        libraries.
        >
        Perhaps so, but where *is* all that pre-written and tested code? Every
        These discussions always devolve into a demand for "pre-written and
        tested" code. To have pre-written code, you have to have written some
        code at some time that is re-usable. If you don't have that, it is
        likely because you have been cobbling together bits of other people's
        code.
        time somebody asks for a good library (as in collection of code that
        helps to deal with browser quirks and incompatibiliti es), they're told
        that there is no such thing. If they dare to mention one of the popular
        You know that is not true. In general, general-purpose browser
        scripting libraries are a bad idea. Collections of code (good code)
        are not a bad idea and have been published (here and other places) by
        numerous contributors.
        libraries, they get flamed to cinders. If such a collection exists, I
        Public contradiction of dubious advice is invariably referred to as
        "flaming" by those whose "sensibilit ies" it offends. If you had spent
        months or years in the comfort of your own little vacuum, writing
        browser scripts to great accolades from your peers, and then find
        yourself summarily contradicted in the real world, it is likely to be
        an unwelcome shock. You can react one of two ways (think again or
        complain about some perceived hatred and flaming.)
        would very much like to know where to find it.
        Didn't we just have this discussion?
        >
        "Demonstrat ed", did he? While there inevitably will be features that
        cannot be detected (though far fewer than may people would like to make
        out) I have to question whether John Resig demonstrated any of them in
        that article.
        >
        (snipping your test cases) You're right. I had already tried to
        duplicate the problems mentioned by Resig and couldn't reproduce them
        either. Maybe the errors only happened with very obscure configurations,
        See my post on the subject. It is a behavior that I stumbled upon
        years ago. I never wrote a blog entry about it, but I have posted
        about it numerous times in this group. John Resig stumbled on the
        same thing, failed to understand it at all, and posted his comedy bit
        about phantom calls to getAttribute.
        or maybe he's just wrong. Who knows. It doesn't really matter though,
        He's just wrong. With him, that is virtually always a good
        assumption. Never mind how many idiots in the publishing industry
        think otherwise.
        because the point was that object detection isn't a cure-all for
        cross-browser scripting, and I agree with that.
        He had no point and therefore proved nothing.
        >
        Given that this assertion is demonstrably BS may attitude toward the
        previous "demonstrat ed" issue on Safari, in light of my test, leans
        heavily toward dismissing that as also being BS.
        >
        Probably. Still, using bad (or let's be nice and say unreproducible)
        No, bad.
        examples doesn't necessarily invalidate the main focus of the article,
        Certainly it does. The whole thing is an attempt to justify his own
        incompetence. The Prototype people have published similarly ill-
        conceived rants (my favorite involved the display style.) You have to
        wonder why anybody would trust code from any of these "programmer s."
        I wouldn't take a batch file from any of them, let alone a script that
        might turn users away from my site. (!)
        or at least the point that I found interesting - which is adding the
        JQuery test suite to the Mozilla test suite. It's *possible* that a new
        Worthless as jQuery is almost entirely hinged on user agent
        detection. Think about that.
        browser version could introduce bugs like the ones Resig used in his
        examples (even if they didn't exist now), or uncover bugs in the JQuery
        library. Testing a browser with a widely used library is a good thing.
        See my numerous posts on feature detection and testing. Peter
        published a nice blog entry on the subject as well:



        (though the CSS seems to be malfunctioning! )
        >
        From my own experience; when IE 7 was released I was working on a web
        application with (at the time) 100,000 lines of client-side code (code
        employing nothing but feature detection where it is necessary to react
        to divergent environments). The total number of changes in the scripts
        needed to accommodate IE 7 was zero. When Chrome was released the total
        number of changes necessary to accommodate that was also zero. And last
        week QA started testing that application on IE 8. They may take another
        week to run through all there tests but so far they have found no
        issues, and I have a realistic expectation that they will not (as pretty
        much everything that would be likely to be problematic would inevitably
        get used in the first day or so).
        >
        Now that is "Future Proof" javascript, and low maintenance javascript.
        >
        That's very impressive. In an application of that size, I'd expect to
        find issues even without accounting for new browsers. I assume that your
        Your expectations are set realistically low. I would expect much the
        same from your code at this point (you have a lot to learn.)
        requirements are vastly different from those who want to build a flashy
        site with moving objects and whistles and bells.
        Irrelevant. You don't get more "whistles and bells" than the project
        I have spent the last half year on. Yes, moving things, special
        effects, etc. can be future-proof (sure as hell not with jQuery
        though!)
        >
        Make use your IE status bar is visible and watch the
        displayed number as you click, mouse-down, move the mouse, release the
        mouse button. And when you have done that see what you think of Resig's
        conclusion that "What happened is positively bizarre: The callback
        function will be executed every time the user left clicks the mouse,
        anywhere in the document." In reality ckicking, and click events have
        nothing to with IE's behaviour, beyond their representing a mousedown
        followed by a mouseup.
        >
        Looks like he was on the wrong track with his test, and you're the first
        He was in the wrong rail yard.
        person who's figured it out... (and the quirk looks even weirder now).
        I'm not about to defend his misjudgement, I just don't think he took it
        That would be difficult. He doesn't do it, so why should you try?
        very seriously. He probably considers himself part of the "Web 2.0
        wave", whatever that is, so he tossed out a blog entry about a curious
        Ah yes, "New Wave JavaScript." He is part of a new wave of
        incompetent programmers who insist on "teaching" others how to do
        everything in the worst possible way.
        quirk without much research, to let the community figure it out and play
        with it. I really don't think this could or should be used to discredit
        him. What he does in his library is a different matter.
        He writes code as he writes blogs (incompetently. ) What should he get
        credit for? Exhorting and enabling hordes of incompetent Web
        developers to add browser scripting to their acts?
        >
        As I said, I'm still convinced that checking browser types/versions
        can't always be avoided. But since both you and David say that it not
        Give me one example where it absolutely *cannot* be avoided.
        only CAN be done, but HAS to be done, I'll try a little experiment and
        ask the group whenever I'm tempted to write [if browser is MSIE6]. If I
        can find solid cross-browser solutions for these problems, I'll gladly
        retract my statement.
        Then you are a better man than John Resig.

        Comment

        • Conrad Lender

          #49
          Re: Help Jquery: unable to register a ready function

          David, I'm not going to continue this discussion with you, until you
          decide to skip the insults and at least pretend to be civil. The
          constant digs at the "incompeten ce" of JQuery and its author are also
          getting old, and don't need any further comments. But this does:

          On 2008-11-05 22:27, David Mark wrote:
          >Perhaps so, but where *is* all that pre-written and tested code?
          >
          These discussions always devolve into a demand for "pre-written and
          tested" code. To have pre-written code, you have to have written
          some code at some time that is re-usable.
          So, to build a nice, dynamic site one has to build up a collection of
          tried-and-tested cross-browser functions first. Of course, getting to
          know all the little gotchas will take years, but that's okay, as long as
          you don't use a library.
          Every other language has its libraries and module archives; but we're
          different. We're building it all ourselves. Because the library writers
          are all "incompeten t".
          >would very much like to know where to find it.
          >
          Didn't we just have this discussion?
          If you're hinting at your own library (again), I'll have to reply
          (again) that without a Free Software license it's not much use for most
          people. If we're following the previous pattern, this is the point where
          you get angry with me.
          It's not: http://peter.michaux.ca/articles/omg...-is-old-school

          Great idea, btw.


          - Conrad

          Comment

          • Richard Cornford

            #50
            Re: Help Jquery: unable to register a ready function

            Conrad Lender wrote:
            Thanks for your thorough and interesting reply. I agree with
            much of what you wrote, so I'll focus on the direct questions.
            >
            On 2008-11-05 18:07, Richard Cornford wrote:
            >[e-commerce sites] Every time someone in that set is excluded
            >from the group from whom money can be taken that is a direct
            >result of a design decision. [..]
            >So we come to trade-offs; is the increased turnover that will
            >result from a more professional presentation greater than the
            >loss in turnover that may result form designing out the
            >possibility of the user of some browsers from accessing the
            >site at all? How do you make those judgments, and who should
            >be making those decisions, and based on what information,
            >knowledge and experience?
            >
            This boils down to the question which user agents an
            application is designed to support,
            But that particular aspect of the design problem is never (or should
            never be) the first step in the process, and may be a long way
            downstream of the start of the design process. It may be very
            significant to everything that comes after it but it would be a mistake
            to promote it to a primary position in the design process.
            and who makes that decision. Only the client is in
            a position to decide who to shut out,
            Yes, it is a business decision and should be made by the person with the
            business responsibility based on the best information available.
            and he will (or should) base this
            decision on his customer base,
            Yes, the customer base, or "target audience". The question is, though,
            what is the relationship between potential customer demographic and the
            type of web browser they use? Beyond trivial observations such as that
            the majority of any population will be using the most popular web
            browsers (by definition), or that IT (and particularly web development)
            professionals are the group moat likely to either be using a non-common
            web browser or a non-default configuration of a popular browsers.

            Last week I bought a wristwatch over the Internet, from the third site
            attempting to sell them as the first two had designed out the
            possibility of taking money off users of non-default configurations of
            IE 6. So what then is the relationship between the web browser choices
            and the warring of wristwatches?
            collected browser statistics,
            Despite the fact that HTTP precludes the possibility of gathering
            accurate statistics by it very nature, that web statistics gathering
            points are not necessarily representative (generally, or of any
            particular 'target audience'), that the statistics gathering process is
            self-biasing and that the resolution of most gathered web browser usage
            statistics is limited to the ability to discriminate between web
            browsers by examining the User Agent string (baring in mind that there
            is no technical justification of a belief that web browsers can be
            discriminated between by using the UA string, and there are demonstrated
            cases were such discrimination is impossible)?

            How many business people will understand the true status of any web
            statistics they are shown? And how many developers will accurately
            explain their status. Experience of discussing this point over the years
            suggest that huge percentage of web developers take web statistics
            purely on faith, assume they are meaningful and then employ them as a
            convenient justification for doing precisely what they were going to do
            anyway (the 'chicken and egg' situation that self-biases browser usage
            statistics).
            and the advice of his technical staff and developers.
            Which rather assumes that these technical staff and developers have
            sufficient understanding of the subject to give meaningful advice.
            Everything that acts to facilitate the inexperienced or
            non-knowledgeable getting into those positions reduces the odds of their
            advice being accurate/worthwhile, and there is certainly no point in
            expecting the business people to understand the issues.
            Amazon will reach a different conclusion here than, say,
            YouTube, or a gaming site, or a portal for Ajax fans.
            Assuming that that for them the outcome was an active conclusion, rather
            than just the coincidental side effect of the developers they employ,
            they probably should have come to differing conclusions about how much
            browser support is in their best interests. Ironically, though, given
            that web developers are the single group most likely to be using
            non-standard browsers, "portal for Ajax fans" do have a horrible
            tendency to plum for one of the popular libraries and so render
            themselves non-functional for a proportion of what you would imagine
            would be their "target audience".
            Dropping support for ancient user agents can help keep the
            code base managable and reduce the maintainance effort.
            Can, but does not necessarily. An architecture that is a hierarchical
            structure of discrete components would only exhibit the browser specific
            code in the lowest layers so the removal of support for ancient browsers
            would not impact on the manageability of the totality, and code branches
            for ancient browsers is, inevitably, old and well tried and tested, so
            its presence should not impact much on maintainability , and so its
            removal would not necessarily improve maintainability .
            I would never say that JQuery is suitable for any site; but
            for some sites the target audience will be overwhelmingly
            likely to use one of the browser versions that JQuery
            supports.
            Can, but does not necessarily. An architecture that is a hierarchical
            structure of discrete components would only exhibit the browser specific
            code in the lowest layers so the removal of support for ancient browsers
            would not impact much on the manageability of the totality, and code
            branches for ancient browsers are, inevitably, old and well tried and
            tested, so their presence should not impact much on maintainability , and
            so their removal would not necessarily improve maintainability .
            For personal sites, the owner gets to decide. A private blog,
            for example, would be much less affected by the reactions of
            the <1% of visitors whose user agent isn't in JQuery's list.
            That rather assumes the real number to be <1%. Where would that
            statistic be coming from?

            If there is one trend that should be obvious in the generality of public
            internet web development it is the rise of HTTP (rather than WAP)
            browsers on ever more capable mobile phones. How many of those browsers
            are on the "JQuery list"?
            Anyway, I wasn't trying to recommend or defend JQuery, I
            was only talking about the linked articles.
            Fine, but I hope you are starting to understand why they are not held in
            much regard here.
            >>instead of hand-rolling yet another
            >>cross-browser event abstraction layer, for example.
            >>
            >This, oft repeated, assertion that the only alternative
            >to using a third party general purpose library is write
            >everything from scratch for yourself is a total nonsense.
            >In-between those two alternatives lay a whole spectrum of
            >code re-use opportunities, and only the very masochistic
            >are not re-using pre-written code for the bulk of their
            >projects even if they are not using the 'popular' general
            >purpose libraries.
            >
            Perhaps so, but where *is* all that pre-written and tested
            code?
            It is everywhere. Quit a lot of it is in the archives for this group.
            Now if you want it all bundled up together and handed to you on a plate
            then you may be asking too much of whichever unknown other you expect to
            do that work. Personally, I have a well paid full time job writing
            javascript and a preference to spend what spare time I have to devote to
            the subject promoting the understanding of browser scripting rather than
            handing out code.
            Every time somebody asks for a good library (as in collection
            of code that helps to deal with browser quirks and
            incompatibiliti es), they're told that there is no such thing.
            Which would be an accurate description of the situation.
            If they dare to mention one of the popular
            libraries, they get flamed to cinders. If such a collection
            exists, I would very much like to know where to find it.
            Well, mine is on a number of hard disks and backup CD here and at work.
            That does not do you much good, but I suspect that if you made the
            effort to find where they have been posted to the group you would learn
            a grate deal more from the search than you would by just being handed
            the end result.
            >"Demonstrated" , did he? While there inevitably will be
            >features that cannot be detected (though far fewer than
            >may people would like to make out) I have to question
            >whether John Resig demonstrated any of them in that
            >article.
            >
            (snipping your test cases) You're right. I had already tried to
            duplicate the problems mentioned by Resig and couldn't reproduce
            them either. Maybe the errors only happened with very obscure
            configurations,
            That is quite unlikely. John Resig is not motivated to play with browser
            configurations much as doing that would expose how vulnerable JQuery
            code is when they are not in there default state. And try as you might
            there is not a grate deal that you can deduce about a browsers
            configuration form its UA string.
            or maybe he's just wrong.
            So you are not buying David's "incompeten t idiot" theory?
            Who knows. It doesn't really matter though,
            because the point was that object detection isn't a cure-all
            for cross-browser scripting, and I agree with that.
            I would agree with that too. but the truth is that feature detection is
            considerably more general, reliable and effective than any of the
            alternatives, and so the flaws that it does have do not in any way
            indicate abandoning it in favour of any of its inferior alternatives.
            (And then if either of the alternatives is to be used it should be
            object inference browser detection rather than UA string based browser
            detection, as that is by far the superior of the available
            alternatives).
            >Given that this assertion is demonstrably BS may attitude
            >toward the previous "demonstrat ed" issue on Safari, in light
            >of my test, leans heavily toward dismissing that as also being
            >BS.
            >
            Probably. Still, using bad (or let's be nice and say
            unreproducible) examples doesn't necessarily invalidate the
            main focus of the article,
            Employing bogus arguments do not do the credibility of the author any
            good.
            or at least the point that I found interesting - which is adding
            the JQuery test suite to the Mozilla test suite. It's *possible*
            that a new browser version could introduce bugs like the ones
            Resig used in his examples (even if they didn't exist now), or
            uncover bugs in the JQuery library.
            So would that be the position that "future proofing" should not be
            addressed by writing code that does not need updating with each browser
            release but instead responsibility should be handed off to browser
            manufacturers? That would be an optimistic notion given that browser
            manufacturers already strive not to produce browsers that look broken
            when exposed to the web, and yet the situation we find ourselves in is
            the situation that it is.

            You should remember that the current set of 'popular' libraries were
            designed by relative novices who only had a very superficial familiarity
            with the reality of web browsers (all of JQurey, Prootype.js and DoJo
            certainly fall into that set) and that the totality of their manifest
            misconceptions may not be reconcilable.
            Testing a browser with a widely used library is a good thing.
            From the point of view of a browser manufacture, it is a sensible thing
            to do for pragmatic reasons. It does then no good to produce something
            that promptly looks broken on a significant number of web sites. From
            the library author's point of view, it is also a good thing because it
            will become a barrier to their having their misconceptions and mistakes
            exposed. Unfortunately, the latter does not serve the greater good as it
            will get in the way of allowing the library authors from learning from
            their mistakes.
            >From my own experience; when IE 7 was released I was working
            >on a web application with (at the time) 100,000 lines of
            >client-side code (code employing nothing but feature detection
            >where it is necessary to react to divergent environments). The
            >total number of changes in the scripts needed to accommodate
            >IE 7 was zero. When Chrome was released the total number of
            >changes necessary to accommodate that was also zero. And last
            >week QA started testing that application on IE 8. They may
            >take another week to run through all there tests but so far
            >they have found no issues, and I have a realistic expectation
            >that they will not (as pretty much everything that would be
            >likely to be problematic would inevitably get used in the
            >first day or so).
            >>
            >Now that is "Future Proof" javascript, and low maintenance
            >javascript.
            >
            That's very impressive. In an application of that size, I'd
            expect to find issues even without accounting for new browsers.
            Yes, but my point only relates to changes that needed to be made to
            accommodate newly released web browsers, as that is the aspect pertinent
            to the subject of future proofing and maintainability .
            I assume that your requirements are vastly different from those
            who want to build a flashy site with moving objects and whistles
            and bells.
            Yes and no. The application is a serious business application sold to
            large commercial concerns. However, the CEO loves bells, whistles and
            moving objects. He maintains that they make the application easier to
            sell because they catch the attention of the management who will be
            making the purchasing decisions. On the other hand, he also loves the
            application to perform as quickly as possible, asserting that also makes
            it easier to sell. Those tend to be contradictory demands.

            <snip>
            >.... And when you have done that see what you think of Resig's
            >conclusion that "What happened is positively bizarre: The
            >callback function will be executed every time the user left
            >clicks the mouse, anywhere in the document." In reality
            >ckicking, and click events have nothing to with IE's behaviour,
            >beyond their representing a mousedown followed by a mouseup.
            >
            Looks like he was on the wrong track with his test,
            Yes, but the point is that the false conclusions were the inevitable
            outcome of his making a novice mistake in this testing strategy.
            and you're the first
            person who's figured it out...
            Unlikely. Anyone with any reasonable practical experience of examining
            web browsers behaviour would have seen that the conclusions were likely
            to be wrong due to the flawed testing strategy. It is then just one
            simple step to fix the testing strategy and expose the reality.
            (and the quirk looks even weirder now).
            I'm not about to defend his misjudgement, I just don't
            think he took it very seriously.
            And this is you not defending him?
            He probably considers himself part of the "Web 2.0
            wave", whatever that is, so he tossed out a blog entry
            about a curious quirk without much research, to let the
            community figure it out and play with it.
            Seems unlikely. Not least because his 'community' is far too credulous
            not to take whatever they see at face value.
            I really don't think this could or should be used to
            discredit him.
            What? A self-proclaimed "JavaScript Ninja" making novice mistakes does
            not speak to credibility?
            What he does in his library is a different matter.
            I don't think where the novice mistakes get made makes that much
            difference.
            As I said, I'm still convinced that checking browser
            types/versions can't always be avoided. But since both you
            and David say that it not only CAN be done, but HAS to be done,
            I'll try a little experiment and ask the group whenever I'm tempted
            to write [if browser is MSIE6].
            We still have not seen how your 'if MSIE6' decision would be made.
            If I can find solid cross-browser solutions for these problems,
            I'll gladly retract my statement.
            Yes, why not give it a try. But don't be surprised if you are expected
            to interactively participate in the process (i.e. actually answer the
            questions you get asked). There is no such thing as a free lunch on
            comp.lang.javas cript.

            Richard.

            Comment

            • Richard Cornford

              #51
              Re: Help Jquery: unable to register a ready function

              Conrad Lender wrote:
              <snip>
              On 2008-11-05 22:27, David Mark wrote:
              >>Perhaps so, but where *is* all that pre-written and
              >>tested code?
              >>
              >These discussions always devolve into a demand for
              >"pre-written and tested" code. To have pre-written
              >code, you have to have written some code at some time
              >that is re-usable.
              >
              So, to build a nice, dynamic site one has to build up a
              collection of tried-and-tested cross-browser functions first.
              That is certainly one way of doing it.
              Of course, getting to know all the little gotchas will take
              years,
              No it doesn't. The first thing to learn is how to accurately pin down
              the cause and effect relationships behind the "little gotchas". With
              enough effort put in, and sufficient critical (and I mean critical)
              feed-back, that should not take more than a month of two. After that the
              cycle of handling each browser issue encountered is relatively short,
              and in practice you only have to handle issues as they arise, and if
              done property the first time, once only.
              but that's okay, as long as
              you don't use a library.
              Every other language has its libraries and module archives;
              And very few of them have deployment/distribution issues that are
              inherit with javascript.
              but we're
              different. We're building it all ourselves.
              Building up your own "collection of tried-and-tested cross-browser
              functions" and writing them all yourself are not the same thing.
              Because the library writers
              are all "incompeten t".
              <snip>

              That is a pity, isn't it. Have you wondered how it could be that the
              world could contain competent browser scripters and yet it is the near
              novices who set about designing/writing the general purpose libraries?

              Richard.

              Comment

              • David Mark

                #52
                Re: Help Jquery: unable to register a ready function

                On Nov 5, 5:34 pm, Conrad Lender <crlen...@yahoo .comwrote:
                David, I'm not going to continue this discussion with you, until you
                decide to skip the insults and at least pretend to be civil. The
                constant digs at the "incompeten ce" of JQuery and its author are also
                getting old, and don't need any further comments. But this does:
                >
                On 2008-11-05 22:27, David Mark wrote:
                >
                Perhaps so, but where *is* all that pre-written and tested code?
                >
                These discussions always devolve into a demand for "pre-written and
                tested" code.  To have pre-written code, you have to have written
                some code at some time that is re-usable.
                >
                So, to build a nice, dynamic site one has to build up a collection of
                tried-and-tested cross-browser functions first. Of course, getting to
                know all the little gotchas will take years, but that's okay, as long as
                you don't use a library.
                Every other language has its libraries and module archives; but we're
                different. We're building it all ourselves. Because the library writers
                are all "incompeten t".
                >
                would very much like to know where to find it.
                >
                Didn't we just have this discussion?
                >
                If you're hinting at your own library (again), I'll have to reply
                (again) that without a Free Software license it's not much use for most
                people. If we're following the previous pattern, this is the point where
                you get angry with me.
                >>
                (though the CSS seems to be malfunctioning! )
                >
                It's not:http://peter.michaux.ca/articles/omg...-is-old-school
                >
                Great idea, btw.
                >
                  - Conrad

                Comment

                • Eric B. Bednarz

                  #53
                  Re: Help Jquery: unable to register a ready function

                  Thomas 'PointedEars' Lahn <PointedEars@we b.dewrites:
                  Eric B. Bednarz wrote:
                  >[...] The only thing that keeps me from considering you and Thomas Lahn
                  >to be jQuery’s most effective – albeit somewhat unintentional –
                  >ambassadors in this NG is having read its source code myself;
                  >accidental readers are unlikely to share this advantage.
                  >
                  That argument is fallacious as it is based on the false assumption that
                  discussing the shortcomings of a piece of software attracts a majority of
                  relevant users to exactly that software.
                  No it isn’t. It is based on the true assumption that name-calling for its
                  own sake serves no particular purpose other then egotainment (there’s
                  nothing wrong with that in the context of Usenet, as far as I am
                  concerned, but it is only amusing for people who are sufficiently
                  interested in the topic at hand already). It’s not only about what you
                  say, but how. And if you do not know that how you say something can have
                  the opposite effect on your environment, well, than I’d think that’s
                  lack of experience (David Mark has pointed out repeatedly that it is
                  lack of interest in his environment in his case, so I willingly take his
                  word on that).

                  If you like to know, last year I have been looking for convincing
                  (external) arguments against (the popular) general purpose libraries in
                  this NG and I couldn’t find any for the target audience. At least, not
                  in the broad sense, by – more or less – complete thread (‘the community
                  has spoken, professionallyâ €™). Just like in this thread, there’s usually
                  just Richard, very verbose, very accurate, very professional (which is
                  to say, sharp, but not ridiculous, and also very lonely at all of that),
                  and, implicitly, very expensive, or there would be more of the same
                  quality. And a lot of noise.

                  Comment

                  • Eric B. Bednarz

                    #54
                    Re: Help Jquery: unable to register a ready function

                    David Mark <dmark.cinsoft@ gmail.comwrites :
                    Eric B. Bednarz <bedn...@fahr-zur-hoelle.orgwrote :
                    >I *do* have one good thing to say about jQuery: I hate G2 much more.
                    >
                    You hate something I have never heard of more than jQuery.
                    You could just stop posting until you know better, how about that?
                    >Not? The only thing that keeps me from considering you and Thomas Lahn
                    >
                    What does he have to do with it?
                    Sorry to throw you in the same basket. Apparently he isn’t too cheap to
                    consult a proper nntp server, my mistake, probably.
                    Do you think he is the only other
                    member of the group to question the competence of the jQuery project?
                    Oh no. The valuable information just didn’t originate from either of you.
                    Perhaps you are reading a different newsgroup?
                    Now *that* is more interesting in more senses than you could ever
                    understand. And the answer is certainly yes.

                    Comment

                    Working...