Today I Learned - Rocky Kev

TIL How to convert a jQuery plugin to Vanilla JS

POSTED ON:

TAGS:

It's not that I think jQuery is awful or anything.
It's more that it's outdated (with security risks), the conveniences that jQuery provided have been incorporated into Vanilla JS, and you need to bundle jQuery with your code to make it work.

For example: to use Lettering.js, which is a reallky neat library, you need to bundle jQuery with it.

Projects like this make me happy:
Converting a jQuery plugin to vanilla JS: Lettering.js

The original jQuery version:
https://github.com/davatron5000/Lettering.js/blob/master/jquery.lettering.js

The updated Vanilla version (by Chris Ferdinandi):
https://gist.github.com/cferdinandi/68bae3f551d7daff8d442e232c499307


Related TILs

Tagged:

TIL what is npm Script

Despite their high usage they are not particularly well optimized and add about 400ms of overhead. In this article we were able to bring that down to ~22ms.

TIL fancy methods to transform Javascript Objects

You can use Object.entries(), Object.keys(), Object.fromEntries()...

TIL how to hide your JS code

ONE THING TO NOTE: Encrypting a script is stronger than obfuscation, both methods are still not adequate to protect secret content. Honestly, I don't think it's worth it on a production site, and instead just go with pure server-side if you want security. But it's fascinating.