DEV Community

Discussion on: Creating a toggleable dark mode theme

Collapse
 
ianwijma profile image
Ian Wijma •

Hey, curious why you use jQuery for one piece of the code, where the rest of the code is just vanilla JS :D

$(window).on("load",loadDark());
Enter fullscreen mode Exit fullscreen mode

Could be replaced with:

window.addEventListener('load', () => loadDark());
Enter fullscreen mode Exit fullscreen mode
Collapse
 
sbrevolution5 profile image
Seth A Burleson •

Sorry for the late response on this, I've been grinding hard the past few weeks. I am learning jQuery and using it elsewhere in the project, not to mention I'm on bootstrap 4 so its already included. In the end its basically the same thing, a little more concise. I'm tending to like jQuery more and more, which you may see in a post later today ;)

Collapse
 
ianwijma profile image
Ian Wijma •

LOVE seeing passion and hard work! I personally would suggest learning the native functions over jQuery.

jQuery was created to overcome major inconsistencies between browsers. Which is less the case now-a-days. I would recommend checking online sources like You-Dont-Need-jQuery (github) or (Now More Than Ever) You Might Not Need jQuery (csstricks). :)

But like all technologies, its up to you if you want to use it or not!

Note: Bootstrap 5 does not uses jQuery out of the box. Although it does support it. ref

Thread Thread
 
sbrevolution5 profile image
Seth A Burleson •

To me, the jQuery stuff is so much easier. Just look at document.getElementById("myBigOldId").value vs $("#myBigOldId").value. But I totally see it becoming outdated, since it doesn't do anything "new".