Staring keenly at a stack of magazines, I hazard a gaze towards the computer
section and lay my eyes upon the newest cover of my sworn enemy, the .NET
magazine. Its luring front-page convinces me that it deserves my consideration.
I buy it without looking inside. I want to reserve the surprise for later.
Now sitting in the lounge at London Gatwick Airport, I whip out the magazine
and rush to a JavaScript article. I can’t wait. It’s about jQuery and I just know
that they’ve gotten their act together since previous encounters. I’m sure this
article will contain the best in jQuery techniques and JavaScript best practices.
Well, .NET, now I’m sitting here with the unfortunate duty to inform you of my
unsurprising disappointment.
The truth is I expected nothing more from you.
Please turn to page 80 of issue 205 and pay special consideration to the
following reservations of mine:
The author doesn’t mention the possibility nor the applicability of creating a
jQuery plugin instead of the single globally defined function ‘drawerToggler’.
What’s wrong with this? Well, the function happens to contain functionality that
could be abstracted to deal with arbitrary sets of nodes and is therefore suited
to jQuery’s plugin mechanism. I would understand if at least a mention surfaced,
but nothing.
This is certainly not the worst of it though.
The function itself:
function drawerToggler() { $('#theme-drawer').slideToggle("normal", function(){ if ($('#theme-drawer').is(":visible")) { $('#wrapper').css("margin-bottom", "150px"); } else { $('#wrapper').css("margin-bottom", "20px"); } }); } |
Where it’s being called:
$(document).ready(function(){ $('.drawer-toggler').click(function(){ drawerToggler(); }); }); |
This function is called within the click event handler for any element with a
className containing drawer-toggler
. Since it’s getting called on every click,
and the elements selected within the drawerToggler
do not change between calls,
it would be logical to select and “cache” the DOM object references beforehand,
and then the function could use these DOM references instead of continually
(and redundantly) re-querying the DOM on every single call!
The function itself contains some redundant code too. The ‘theme-wrapper’ to
which the slideToggle
method is applied, is then re-queried within the callback.
Apparently unbeknown to the author, this very element can be accessed via the
‘this’ keyword within the callback function — there is absolutely no need to
re-query the DOM for #theme-wrapper
!
This isn’t just a case of my preferences versus the author. There are established
best practices in the jQuery community and as one of the industry’s top
publications you should be providing not only good advice but near enough the
best advice according to current industry practices and standards.
Now, I could stop, but the reign of nonsensical JavaScript programming continues.
On page 82, along with the insistence of using $(this).attr('rel')
instead of
the terser and faster DOM equivalent, this.rel
, the author insists, again,
on re-querying the DOM for unchanged elements within the click event handler for
all anchor elements within #themes-wrapper
!
There’s a few more specific issues I’d like to raise but I feel I’ve already made my point in regards to the obvious inadequacy of the article itself.
The article specifically says that it’s geared towards developers with an
intermediate-level understanding of HTML, CSS and JavaScript. If you want to
further the knowledge and understanding of these developers then you must, as
reason would dictate, have a teacher that presents a higher-than-intermediate
understanding of these technologies.
Before you suggest that I write an article to amend previously made mistakes (“Instead of complaining write your own article.. blah blah blah”) I’d
like to let you know that I will do no such thing. It is your responsibility to
find the best authors and the best content featuring the topic at hand.
I write
this letter not only because I care, but because I am desperately worried, as
are many others, about the state of jQuery within the JavaScript community, and
more generally the lacking understanding that is slowly rotting the core principles of
JavaScript from under its feet. Let the ignorance stain the ranks of beginners
and hobbyists, as it always has and always will, but let it not protrude into a publication that claims to
encapsulate the ever-changing essence of the web industry. Stop pandering to
the lowest common denominator and be the best!
I realise that, from a
monetary perspective, such concerns are likely to be lower on your priority
list than getting that new coffee machine for your staff, but for the love of
what you claim to stand for, prove to me that you are more than what I dare think
you may just be — another profit-based publication whose sole concern is the
quantity of its readership rather than the quality of its content.
If you’re going to publish articles relating to JavaScript then you’re going to
have to tighten your belt and get to work. It’s not a playground. Currently,
you’re only serving as a catalyst to the ignorance that a magazine such as
yours should be out to destroy.
If you think this letter is not worthy of your consideration, then discard it as one of many (no doubt) complaints, for I am only too happy to accept that I’m right about you!
Prove me wrong. I dare you.
JAMES PADOLSEY
Thanks for reading! Please share your thoughts with me on Twitter. Have a great day!
jQuery, it’s Javascript… but only if you know Javascript 😉
you no doubt have raised a valid point, I hope they acknowledge your letter and improve the content quality in the future.
P.S.- I am an admirer of your skills 🙂
.NET is published by a gigantic, faceless commercial publishing company just like most other magazines; you only really need to look at their website to realise how much of a joke their seriousness about web technologies is.
I suspect they’re appealing to the lowest common denominator because that’s where the majority of the money is.
I’ve purchased the .Net magazine a few times, and I’ve come to the conclusion that it’s a publication for hobbyists, by hobbyists (with an occasional exception).
They will find people to write about whatever is hyped (i.e jQuery, HTML5) because it sells, regardless of the quality of the actual content.
Anyone like you and me wouldn’t (normally) purchase the magazine because we don’t really find it worthwhile anyways, and that’s why the quality of the code remains at a level were hobbyists can copy/paste, and it works, and they’re happy. Which is obviously kind of sad, but again, it seems to work for them.
Regarding the state of jQuery within the JavaScript community: I think that battle is partly lost, and it’s nothing that can be controlled, there’s so much shitty code out there and people don’t care, they just go along, copy it, use it, as long at it works at a very basic level. That’s the nature of the web.
Am I being pessimistic? 😛
Get’em telt!
The alternatives you are proposing are on a million blog posts on how to write jQuery.
if their JS author was as good as their magazine cover designers then we wouldn’t be reading this article.
Despite their hype to the contrary, it’s not a magazine for professionals – unless you’re a professional graphic designer. I bought an issue 2 months ago (at Waterloo, grabbed reading material for the train) and all the magazine told me was that pretty designs = great web design. One day I’ll have a blog again and publish my review…
Tech magazines always suck. I stopped buying or reading them ages ago… All my readings now is from blogs …
Reason I like reading from blogs is that the articles are always backed fresh! and the comments and interactions add valuable information. The readers sometimes point to something the author missed.
Hey James,
Thank you for focusing attention on this. I absolutely love jQuery and use it on a daily basis however, I cannot stress enough the importance of knowing JavaScript as a language and not just relying on jQuery for everything.
Also, it is very important for people using jQuery to really take some time and learn the API in it’s entirety instead of just copying and pasting code. With latter, we are moving back in time to the days of the DHTML snippets people used to cut and paste into their website not knowing whether the code was written well or how exactly it works. Then when things go wrong, Whoa Nelly, watch out 😉
Schalk Neethling
Looks like the author does not know JavaScript. These are kind of people who know jQuery but not js. I know. I was one of them once. Phew! Thank God, I am not now.
All they care is get all page stuffed with web hosting ads!
Its a shame; but what your saying would suggest that they were targeting people with any real knowledge of programming structure or even the jquery best practice or crazier still JavaScript.
jQuery brought what was once rather lengthy JavaScript + DHTML to the masses, I vaguely remember it pushing itself as JavaScript for designers… not front end developers but designers.
Hopefully the people who read these hacked together articles get a taste for jQuery and what its doing for them and then go on to learn more about it. .NET magazine has always been the flashy tart of the web-mag industry pushing out articles on any old crap thats trending so I’m a tad surprised to see anyones still surprised. It keeps amateur designers/students and teenagers calling themselves web designers happy and obviously generates interest for some people. Going off the IT uptake in the UK we need something to get people interested so lets put down the flaming pitchforks and leave it to do what it does best (keeping fat web-lebritities in shiny suits).
Hey look Zeldmans in the next issue http://www.netmag.co.uk/zine/latest-issue/issue-206 ;o)
@Chris, it really doesn’t matter who they’re targeting. If they’re going to publish an article on the topic of jQuery then it is their responsibility to make sure it’s accurate, up-to-date and shows code that complies with best practices. If they can’t at least do that then they really are utterly pointless and only serve to perpetuate an inaccurate image of currently utilised technologies, which isn’t exactly a useful pursuit.
I am by no means a great jQuery developer but I do know quite a bit about the API and make a point of following the best practices etc.
@Chris I do sort of agree with you but I also think that they could at least try and follow some good practices such as using the ‘this’ keyword instead of re querying the DOM.
Also if they want to do articles like this is it not a better idea to start with the real basics of what jQuery is and then issue by issue work your way up. That seems like a much better idea to me, it would also mean people would potentially buy the mag to get the next installment. I remember thats what a couple of the decent IT magazines used to do.
Anyway, I think that unless the editors are completely passionate about what they put into their magazine and make a point of being the best then they are waisting their time and should write about plants or something.
Thats my 2 cents anyway. 🙂
Sock it to ’em! I hope you never inspect some of my code too closely as I’ve probably been guilty of this as well on occasion! Then again, I don’t write for a large magazine with thousands of readers taking my word for granted…
did the .NET Magazine hire a hit-man or something? u’ve been of the radar for a while James…
I’ve submitted a number of code re-writes to this magazine and so far have been completely ignored.
Far too often the examples are extraordinarily irresponsible.
I’ve been a Microsoft Developer for 25 years. I hate ASP.Net but love C# Winform development. The open source word has converted me to move away from the dark side (aka Microsoft). Most developers coding in .Net are mainly pushing .Net due to corporate initiatives anyway. I won’t read their biased inaccurate magazine. Most forms of printed media is going away anyway.
Open source rules!
Thank you for this article! I cannot believe an actual, real, paper, published magazine can contain content this useless!
Also, I very much like your site theme – good work!
For one who is not so experienced as to pick up the mistakes you have, James, what is a good place to start to learn JS like that properly? Can you list any good blogs for HTML/CSS3/JS?