Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Now put down authentication, geolocation stuff, actual state management and see your code expand exponentially.
Frameworks exist for preserving devs' sanity as well ya know ;) -
That's because it's fit for website with few interactivity features. You know what's even faster? Loading speed after removing PHP middleware. Bring JAMstack solution and generate plain HTML at deploy time, DRY. Extending? Svelte it.
-
Hazarth94844y@3rdWorldPoison eh, I wrote plain XHR js authentication, using jwt tokens and with refresh token support. It's like 300 lines of code which is nothing really. (Person project, security was of little concerned at this stage)
@turbopixel
Where Id put the real advantage of frameworks is that they do it and patch it "securely". Otherwise we would all have to constantly react to all sorta of vulnerabilities ourselves.
That being said, It's good practice to know how to do it and It's also true that frameworks do add bloat too so in the end it depends on what your priorities are for a particular project -
Wait till you need to interact with the DOM, states and other interactions where you'll end up having code less maintainable and one that isn't performant, that's where some libraries and frameworks shine.
It's nice to do everything yourself and not depend on library, but that comes at a cost. -
i approve, but i would still want something jQuery-like, just to have the DOM selection and manipulation have sensibly short and straightworward code as opposed to the ridiculous default JS stuff.
getElementById().childNodes.getElementsByTagName().setAttribute(), anyone? XD
oh, hey, querySelector exists now! cool! still too long, would need wrapping into $(), plus some better way for attribute setting/getting.
that (and the fact that i'm too lazy to implement a mini lib that would do the above) is literally the only reason i (still) use jQuery. -
@Midnight-shcode Want my querySelector wraper? I can make a gist tomorrow.
It detects if your selector is simple, in which case it uses the specific method (getElementById, getElementsByClassnames, getElementsByName, etc.) and let's you choose to select the first match, all matches, or n matches with an optional 2nd argument. It even let's you choose the root (root.querySelector...) with the third.
Best of all, it's faster than querySelectorAll (Tested. I can't understand how if it's a freaking wrapper.).
I called it SqS (standing for Super querySelector). -
@Midnight-shcode
Late but here it is. It took me a bit but as it's one of the first pieces of code I ever wrote and I haven't touched it in some time, I wanted to give it a revision.
https://gist.github.com/c3r38r170/...
WTFPL
Any criticism is accepted as well.
Related Rants
I started a new project and only use PHP, HTML, CSS and vanilla JS. No Frameworks. No React. No Vue.
The browser loads the page instantly, there is virtually no loading time and it just works.
random
html
vanillajs
php
oldschool