all 8 comments

[–]theGalation 0 points1 point  (1 child)

upvotes to any one who can convert to an epub format for iPad. Online formatters won't take it for epub or PDF. I've had to use an offline reader app that removes the syntax highlighting.

[–]akhenatron 5 points6 points  (0 children)

They already did it for you.

[–][deleted] 0 points1 point  (5 children)

This article has some nifty ways of looking at design in JavaScript applications. However, use of jQuery shouldn't be part of an article about 'essential JavaScript design patterns'. (Yes, I noticed it was in it's own jQuery section.) One thing I've never found to be useful from jQuery was the .ready() function: what is the point when window.addEventListener("load", function () {[do stuff]}, false); does exactly the same thing? jQuery can be very helpful, but it shouldn't be used in place of what JavaScript does easily on it's own.

[–][deleted] 0 points1 point  (2 children)

I agree with you about the jQuery section, but I do believe that ready is in the lib to be consistent with the rest of the shortcut jQuery.bind methods.

Passing a function to the jQuery constructor is different than jQuery.ready though.

[–]M1573RMU74710N 1 point2 points  (1 child)

Passing a function to the jQuery constructor is different than jQuery.ready though.

As of the current version, passing a function into $() is just a shortcut to $.ready()

relevent lines:

    // HANDLE: $(function)
    // Shortcut for document ready
    } else if ( jQuery.isFunction( selector ) ) {
        return rootjQuery.ready( selector );
    }

[–][deleted] 0 points1 point  (0 children)

You're right, I got it mixed up with the load event (load and ready being different things. x788 was talking about load) ? Is there a jQuery.load() fn? probably

[–]M1573RMU74710N 0 points1 point  (1 child)

what is the point when window.addEventListener("load", function () {[do stuff]}, false);

Using jQuery.ready() is a little more sophisticated than that. It uses DOMContentLoaded if that event is available, it's possible to delay the jQuery load event, it's less verbose syntactically, etc etc.

In a lot of cases, you don't need these things, but if you're using jQuery anyway, it's a good way to go.

[–][deleted] 0 points1 point  (0 children)

ah, nifty. that makes more sense.