I turned Huffduffer into a progressive web app recently. It was already running on HTTPS so I didn’t have much to do. One manifest file and one basic Service Worker did the trick.
I also did a bit of spring cleaning, refactoring some CSS. The site dates to 2008 so there’s plenty in there that I would do very differently today. Still, considering the age of the code, I wasn’t cursing my past self too much.
After that, I decided to refactor the JavaScript too. There, I had a clear goal: could I remove the dependency on jQuery?
It turned out to be pretty straightforward. I was able to bring my total JavaScript file size down to 3K (gzipped). Pretty much everything I was doing in jQuery could be just as easily accomplished with DOM methods like addEventListener
and querySelectorAll
, and objects like XMLHttpRequest
and classList
.
Of course, the reason why half of those handy helpers exist is because of jQuery. Certainly in the case of querySelector
and querySelectorAll
, jQuery blazed a trail for browsers and standards bodies to pave. In some cases, like animation, the jQuery-led solutions ended up in CSS instead of JavaScript, but the story was the same: developers used the heck of jQuery and browser makers paid attention to that. This is something that Jack spoke about at Render Conf a little while back.
Brian once said of PhoneGap that its ultimate purpose is to cease to exist. I think of jQuery in a similar way.
jQuery turned ten years old this year, and jQuery version 3.0 was just released. Congratulations, jQuery! You have served the web well.
6 Likes
# Liked by Ivan Wilson on Sunday, June 12th, 2016 at 7:48pm
# Liked by Plugin Company on Sunday, June 12th, 2016 at 7:48pm
# Liked by jalbertbowdenii on Sunday, June 12th, 2016 at 8:37pm
# Liked by Chris Perry on Sunday, June 12th, 2016 at 9:43pm
# Liked by Claudio (aglioeolio) on Monday, June 13th, 2016 at 2:16am
# Liked by Gabor Lenard on Thursday, June 16th, 2016 at 6:16pm