An Interview With Karl Swedberg

jQuerified With Karl Swedberg

Jun 1st, 2009 in Interviews by Drew Douglass

I recently had the extreme pleasure of chatting with Karl Swedberg about Javascript and web development in general. Karl is the author of several Javascript books such as Learning jQuery and jQuery Reference Guide. Join us as we take a look inside the mind of a humble and talented developer.

PG

Author: Drew Douglass

Hi, I'm Drew and I am a freelance developer and designer. I love all things having to do with PHP, MySQL, CSS, or jQuery. You can find my weekly articles on the ThemeForest blog and at Dev-Tips.com. Feel free to follow me if you're a fellow twitter addict.

For those of us who may be unfamiliar with you and your work, tell us more about yourself and what you do for a living

Fusionary

I'm a (mostly front-end) web developer at a small agency, Fusionary Media, in Grand Rapids, Michigan. At 41, I'm probably older than most web developers, but most of the time I still feel like a kid. Outside of work, I'm very involved with jQuery. I'm on the jQuery project team, and I write about it, train others how to use it, and speak about it at conferences.

How and why did you first get involved with web development?

My very first involvement with web development was in 1995, when I built a simple site for a coffeehouse that I owned. After that I dabbled with web stuff here and there, because I really got a kick out of it, but I didn't start doing it as a job until about four years ago.

What are some of your hobbies when you are not working?

I like to read, run, and hang out with my family. Up until a year ago, I had studied karate for about seven years, and I'm considering starting that up again. I also enjoy photography, discovering new music, and geeking out with my friends.

Tell us more about EnglishRules.com and how the website started.

EnglishRules Screenshot

It's a personal blog of mine that I've been neglecting lately. I can't remember exactly when I started it — 2000? 2001? — but the idea was to provide some information and links for my students. I was teaching High School English at the time. Since then it has become a mishmash of my fleeting interests. In 2003 I loaded up Movable Type and started blogging on it. At some point I thought it would be fun to post a a new word each day from whatever I happened to be reading at the time, so I did that for a while. Then I had the crazy notion that I could answer the world's questions about grammar, punctuation, style, spelling, and so on, but that didn't last long. I posted a bunch of my photography on the site for a while, but that has sort of stalled as well. Probably the biggest motivation to keep it running was to give friends and family a snapshot of what I'm doing, but lately Facebook and Twitter have been filling that need.

When did you first become interested in the jQuery javascript library?

I started using jQuery sometime around May or June of 2006. I still have a copy of "Rev 27" of the jQuery core file from May 2, 2006, before it even had a version number. It's a shame the file is compressed and obfuscated. It would be really fun to dig through it and see how much has changed.

Which came first, LearningjQuery.com or the Learning jQuery book?

LearningjQuery Screenshot

The site came first. After playing around with jQuery for a couple months, I thought it would be a good idea to start documenting what I had learned. I asked John Resig if he'd mind my using the jQuery name and blogging about my experiences, and he was enthusiastic about the idea.

A few months after I started the blog, someone from Packt Publishing contacted me and asked if I'd like to write a book about jQuery — an offer that both flattered and terrified me. I agreed to do it, but only if my friend (Jonathan Chaffer) could write it with me. He is a much better programmer than I am, and I was still just a novice at the time.

Why jQuery? Why not MooTools or Prototype?

jQuery Homepage

Choosing a JavaScript library is a lot like choosing a digital SLR camera (once you take price out of the equation, of course). Why Nikon? Why not Canon or Pentax? I'm not sure anyone can satisfactorily answer these questions based on technical merit alone. A lot has to do with intangibles: community, support, compatibility with your already-established mental models about how things should work and look and feel. People also consider extensibility -- in the form of lenses and accessories for cameras and plugins and widgets for JavaScript libraries. Sure, technical merit does play a part. Performance, features, and reliability are important. But as with the camera companies, the JavaScript library developers continue to leapfrog over each other in these areas, and the best one in any one of these areas today may not be the best in that area six months from now.

The reason I chose jQuery in the first place is that it made sense to me almost instantly. I saw that I could easily transfer my knowledge of CSS to jQuery with its DOM-centered approach. Since then, as I've learned more about advanced JavaScript techniques, I have found plain JavaScript sufficient for dealing with the areas of the language that jQuery doesn't address, and haven't felt a need to rely on a library for those areas. I also love the community spirit and the generosity and graciousness of the other members of the project team and the contributors of the discussion lists.

What part of jQuery, or Javascript in general, do you find that new developers struggle with the most?

The question I see asked most often on the jQuery discussion list (Google Group) is along the lines of "Why do my events stop working after I've inserted elements into my document?" We have a detailed FAQ topic that answers this question. I've written a couple articles on learningjquery.com about it. We have the Live Query plugin and, as of jQuery 1.3, the .live() method that solve the problem. Yet despite all of that, the question still comes up a few times a week.

Besides the jQuery docs, where can users find other jQuery resources to help solve any issues they may be having with the library?

jqueryfordesigners Screenshot

Aside from learningjquery.com and the Learning jQuery 1.3 book, there are quite a few great resources. Remy Sharp has some terrific screencasts on his jQuery for Designers, site and I've seen some great articles from Marc Grabanski and James Padolsey on their respective blogs. The jQuery Google Group is very popular, with over 16,000 members and the #jquery IRC channel on freenode.net is quite active and helpful.

Can you name one feature you wish jQuery came packaged with that it currently does not

I wish the .live() method would work with all event types. Currently it only works with a subset, so you can't use it with change, focus, blur, submit, mouseenter, or mouseleave. I also think it would be cool to allow an anonymous function to be used as an argument for .css(), .val(), and .html() the same way it is for .attr().

What tips or advice can you offer those that are relatively new to Javascript? Should they learn Javascript before they move onto jQuery to better understand the subject matter?

I'm afraid these are going to sound like platitudes, but here goes: Don't be afraid to learn as you go. You don't have to have everything figured out ahead of time. Be willing to make mistakes. Keep learning new things about the language, and try to make connections between what you already know and what you're currently learning.

Can you name some 'bad practices' you see being used often with jQuery?

Sure. One bad practice is using jQuery for something that you could do more easily and efficiently with CSS. For example, web developers for years have been changing the background position of an image sprite when the user's mouse hovers over a link. There is absolutely no reason to use jQuery for this, unless the developer wants the hover-state change to be animated.

Another bad practice is unnecessarily repeating selectors. Instead of creating another jQuery object each time you want to do something to a particular set of elements, chain the methods or store a reference to the jQuery object in a variable and use that.

What are some ways one can improve their knowledge of jQuery and become more efficient when working with the framework?

Read tutorials from reputable sites. Ask questions on the discussion list and read answers to other people's questions. In particular, read everything that Michael Geary and Dave Methvin post on the list. Try to emulate the code of great plugin authors such as Mike Alsup, Ariel Flesler, Jörn Zaefferer, and Brandon Aaron.

jQuery plugin development has really taken off over the past two years, do you have any favorite plugins you frequently use or do you prefer to write your own?

jQuery Cycle Plugin

I often write my own, but I do use a few quite frequently. Every client seems to want some kind of image rotator on their homepage, so I use Mike Alsup's Cycle plugin for that. I also use his Form and Media plugins quite a bit. I often rely on Joel Birch's Superfish plugin and Brian Cherne's hoverIntent plugin when a client wants drop-down menus. Lately I've been using jQuery UI more and more for general widget theming, advanced effects, sliders, and draggable/droppable elements.

Are there any specific features (or lack thereof) that you do not like about jQuery?

I'm not crazy about some of the method names in the API. In very early versions of jQuery, there were two method names for traversing all the way up the DOM tree: .parents() and .ancestors(). When the API was trimmed, .ancestors() was dropped. I would have preferred dropping .parents() instead because I think "ancestors" better describes what is being selected. And while in general I like how jQuery overloads methods, I think the .load() and .toggle() methods take the idea a little too far.

You've written numerous books on jQuery, what is the most difficult part of getting these books published?

jQuery Book

The toughest part is probably just staying on schedule. But it's absolutely essential to set a reasonable schedule ahead of time and stick to it the whole way through.

What do you think the future holds for the jQuery framework?

Most of the changes to the jQuery core are going to be in the areas of performance, stability, and bug fixes. I don't see a lot of new features being added to core. For new features, keep an eye on jQuery UI. There is a lot of great new stuff being developed there.

Do you have any more books that you are planning to publish anytime soon?

I'm one of several technical reviewers for a jQuery cookbook that is in the works. But I'm not currently authoring any books and don't have plans to do so any time soon.

Do you have any shameless plugs you would like our readers to know about?

Nothing that hasn't already been mentioned, but thanks for the offer!

Thank you so much for taking the time to chat with me Karl, and thank you for all the great jQuery resources, tricks, and tutorials you have given to the community over the years.

My pleasure! I'm flattered by your interest in what I have to say.


Related Posts

Check out some more great tutorials and articles that you might like

Enjoy this Post?

Your vote will help us grow this site and provide even more awesomeness

Plus Members

Source Files, Bonus Tutorials and
More for $9 a month for all TUTS+
sites in one subscription.

Join Now

User Comments

( ADD YOURS )
  1. PG

    iPad June 1st

    Great artile, great interview! Thanks

    ( Reply )
  2. nice tutorial,

    awesome!

    ( Reply )
    1. PG

      Gonzalo June 1st

      what’s the point of this replies? “nice tutorial” rofl

      ( Reply )
    2. PG

      Meshach June 1st

      nice tutorial, awesome!

      What are you just trying to spam your URI or something? haha

      ( Reply )
      1. PG

        Omar Abid June 25th

        lots of spam on comments on the tuts network those days, I think moderators have to open eyes and catch them.

  3. PG

    Van damme June 1st

    thanks douglas,,,

    i really like this tutorial,

    thank u

    @pardo
    woi.. domu halak batak do ho kan?? mardia do ho i barat on??

    ( Reply )
  4. PG

    Zy June 1st

    Tutorial? Where?

    You what? Bot or something?

    ( Reply )
  5. PG

    Dario Gutierrez June 1st

    Of course jQuery is much better than mootools and prototype.

    ( Reply )
    1. PG

      Jakob Buis June 1st

      Not true; they’re very different tools for different jobs. For an extended comparison, see http://jqueryvsmootools.com/

      ( Reply )
    2. PG

      Crysfel June 1st

      i don’t agree with you, even if i use jQuery for most of my projects and i really like it, it is wrong to say that jQuery is better that any other framework.

      ( Reply )
    3. PG

      arnold C June 1st

      okay here goes moo tools and prototype fanatics…look out!

      ( Reply )
    4. PG

      Jarod June 1st

      Jquery’s penis is bigger than both Mootools AND Prototypes.

      ( Reply )
      1. PG

        thelastpulse June 1st

        Jarod’s post is most valid.

    5. PG

      Tyler Diaz June 1st

      jQuery is possible more well known than most javascript frameworks, but its just about personal preference to decide which one is better.

      I prefer to use jQuery for projects that uses a lot of interface enhancements. And Prototype for programming specific projects.

      Mootools, jQuery, Dojo, Prototype, Scriptaculous… are all great JS framemworks – Best not underestimating the potential of any.

      ( Reply )
    6. PG

      aldrin June 2nd

      Each framework has different focus.

      I work both in mootools and jquery, and i can really see they have different approach. Though jquery is quite easier and more friendly.

      But for advance coders they like the feel you are still coding a javascript in mootools.

      Anyway whatever you use, as long as what you are comfortable with, then go for it.

      ( Reply )
  6. PG

    mikronaz June 1st

    Great interview! Good luck! Peace! :)

    ( Reply )
  7. PG

    Meshach June 1st

    Great interview, thanks. :)

    ( Reply )
  8. PG

    Dan Sanchez June 1st

    Fantastic interview, I love jquery

    ( Reply )
  9. PG

    Myfacefriends June 1st

    nice interview.

    ( Reply )
  10. PG

    James June 1st

    Really nice interview Karl! I agree with your thoughts on the sometimes lacking semantics of the jQuery API. To be honest, I never knew there existed an “ancestors()” method.

    ( Reply )
  11. PG

    Gary Smith June 1st

    Karl Swedberg? Kinda looks like Dirk Nowitzki. Good info, though.

    ( Reply )
    1. PG

      Karl Swedberg June 1st

      Ha! Yeah, I see a resemblance there.

      ( Reply )
  12. PG

    Soh Tanaka June 1st

    Nice interview, thanks :-)

    ( Reply )
  13. PG

    Muhammad Adnan June 1st

    live method info was new for me ..

    over all good info.

    ( Reply )
  14. PG

    wayno007 June 1st

    Good interview, Drew!

    ( Reply )
  15. PG

    Benjamin June 1st

    hey Karl. I am a Grand Rapids, MI native. Now working in Ann Arbor as a developer.

    Was your coffee shop in GR too? Is it still around? At that period I was drinking lots o coffee (as I am still today).

    ( Reply )
    1. PG

      Karl Swedberg June 1st

      Hi Benjamin,
      Yes, it was called Four Friends Coffeehouse, and was located in downtown Grand Rapids. My wife and I started it with a couple friends in 1994 and then sold it in 1999. The place just shut down last summer after 14 years in business (greedy landlord issues).

      Nice to hear from a local Grand Rapids guy! I’m not a native (was born and raised near Philadelphia), but I’ve called Grand Rapids home for half my life.

      ( Reply )
      1. PG

        Benjamin June 2nd

        Ah, sure. Four Friends – been there many of times. Great coffee and very friendly staff. In ‘97 – ‘98 that was -our- downtown coffee spot.

        Also- As I stated I work in AA (Q ltd) with a woman whose brother (Rex) works at Fusionary. Small world.

  16. PG

    Anton Agestam June 1st

    Totally out of topic: do you have roots in Sweden? Your name sounds extremely Swedish! :)

    ( Reply )
    1. PG

      Karl Swedberg June 1st

      Hey Anton. Apparently my full name, Karl Erik Swedberg, sounds even more Swedish. My grandparents came to the United States from Sweden when they were kids. Although I’ve never been to Sweden, I do identify myself as a Swedish American and usually celebrate Swedish holidays (Midsommar, Valborgsmässoafton, Lucia, etc.) with a small band of Swedes n the area. I even named my daughter Lucia. ;) I would absolutely love to visit Sweden one day.

      ( Reply )
      1. PG

        Anton Agestam June 2nd

        That’s cool! What does your neighbours think when celebrate Lucia? Men in white robes and white cone hats? ;)

      2. PG

        Karl Swedberg June 3rd

        Well, we don’t parade in public. ;) And we leave the star boy robes and hats to kids. (for others who are wondering what we are talking about, you can see a picture here if you scroll down a ways.

  17. PG

    Brandon June 1st

    Nice interview. It’s great to put a face with a name like Karl’s.

    ( Reply )
  18. PG

    Chris June 1st

    Great interview, and a local based developer as well :D

    -Chris
    Waterford, MI

    ( Reply )
  19. PG

    digyourlove June 1st

    Cool
    I just have read the book 《Learning jQuery》.

    ( Reply )
  20. PG

    Diego SA June 1st

    I envy your knowledge Karl! Seeing all the things you’ve been doing is so appreciative and inspiring! Excellent interview!

    ( Reply )
  21. PG

    insic June 1st

    nice interview. good read.

    ( Reply )
  22. Interesting dissection of a bulimic meal. I lost taste for the appetizer and regurgitated the meal. JQuery continues to be the ipod of the javascript frameworks. i really hate that wheel.

    ( Reply )
  23. PG

    helman June 1st

    not bad!

    ( Reply )
  24. PG

    Simon June 2nd

    Nice interview !
    It’s interesting to have the opinion of someone who is involved in the community and is still able to talk about the dark side of the force ;)
    I really should take a look a your books.
    Thanks.

    ( Reply )
  25. PG

    Ethan June 2nd

    Very nice! Good links for beginners like me!

    ( Reply )
  26. PG

    aldrin June 2nd

    It’s very great interview and inspiring in most developers.

    ( Reply )
  27. PG

    jen June 2nd

    Thanks to the good fortune of having a workshop with Karl Swedberg at Future of Web Design, NYC, 2008, I’ve had the courage to try. I may not have the easiest time implementing things, but I’ve found that folks like Karl and Ariel Flesler [http://flesler.blogspot.com] are willing to help. Using prototype and scriptaculous drives me nuts because the documentation isn’t as clear and I just don’t find the support I need. I hope to someday really grasp javascript fully. Every day is a new opportunity to learn more about the DOM.

    Karl Swedberg rocks!

    ( Reply )
    1. PG

      Karl Swedberg June 4th

      You are way too kind, Jen! It’s always a pleasure to work and chat with you.

      ( Reply )
  28. PG

    DynamicGuru June 2nd

    Very Informative…..
    i am just a beginner in jQuery and was building my very first ui 5 hours ago when i got stuck with the very problem Karl stated that developers struggle with the most…I had thought it was becoz of some flaw in my code and was upset about it…If it hadnt been for this article i guess i wouldnt have come to know about the .live() method (atleast not for weeks)…!!!
    Thank you so much Karl!!!

    ( Reply )
  29. PG

    freidz June 3rd

    Go Mavericks!

    ( Reply )
  30. PG

    kumar June 5th

  31. PG

    Brian June 5th

    Feeling very Jqueerified.
    Thanks

    ( Reply )
  32. PG

    Kris Utter June 6th

    Along time ago, when I was just getting into web development and didn’t know a thing about Javascript libraries, I was looking at the ‘Learning jQuery : Better Interaction Design and Web Development with Simple JavaScript Techniques’ book on amazon.com. That same morning I was dispatched to a business to fix a broken Macintoch (I’m an ACMT). While I was there I saw this book in question on the desk of the individual whom I was to instructed to speak to. I ask if he knew much about this book….He looked at me and said “Yes, I wrote it with my friend Jonathan over there”. Karl was very cool with my neophyte questions and even gave me his email address if I had any questions, which I did.

    Kark, props for always giving your co-author so much credit.

    Side note: I used to go to Four Friends, sorry to hear it’s gone.

    ( Reply )
  33. PG

    Quinton June 10th

    All this Jqueeryness gets me excited!

    ( Reply )
  34. PG

    Sumesh June 16th

    Good interview, I like the fact that so many great developers and designers (like Nick La, recently interviewed by a TUTS site, I think it was vectortuts) start off with a personal project or hobby.

    I have a few personal projects too, hope to emulate them at least partially :)

    And you’re spot on about the fact that Karl’s a humble guy – reading through some of the comments and replies from Karl makes me want to see all developers being so ;)

    ( Reply )
  35. PG

    John June 17th

    Thanks for the article, it was a pleasant read, some useful links within it too.

    Karl seems like a really nice guy too, rather modest.

    ( Reply )
  36. PG

    JD October 31st

    Interesting interview, you left out the part where you started out as a copyright editor at structure.

    ( Reply )
  1. Arrow
    Gravatar

    Your Name
    October 31st