7

why do people use so much javascript and <div>

Submitted by twovests in just_post

learning web design

this is surprisingly easy

you can do positioning with CSS

you can do responsive design with CSS

you can do dropdown menus with CSS

i'm researching ballots and.... why are so many people making sites with a loooooooooooot of javascript

javascript for positioning

for style

for layouts

why is it this way?

are people being taught to make sites this way in schools?

is there something i'm missing?

and when i hit "view-source" why are there so many divs?

i mean for real like, there's gotta be use for those divs right. what does a <div><div><div><div></div></div></div></div> do

Comments

You must log in or register to comment.

5

devtesla wrote

both of these problems are caused by web devs using more and more abstract frameworks that add junk to the markup. I think html/css frameworks are usually justified, they can handle weird edge cases and are really easy to build something quick with. most developers don't have time and aren't rewarded for making something that doesn't have <div><div><div> on it

these big javascript frameworks started because people needed to build webapps that work like desktop and mobile apps, but are being used in places that aren't really appropriate in order to add useless visual flair, heavy advertising, and track user behavior

2

twovests wrote

i mean, i can understand html/css frameworks

if i ever make a site, i'm probably gonna slap on one of those cool styles with nice buttons and responsive designs

but i'll still need to fill in where buttons go... and i understand people are somehow using javascript for this? my understanding it was like <button id="cool_logout_button"> and then you hook that up with some Spicy Javascript later down the line?

do you know where the many <div> come from? do they serve a purpose, or are they just extra cruft from the layers of abstraction?

view-source is once again a fresh mystery

2

devtesla wrote (edited )

Using a web app framework to build a website means yea, you can use JavaScript to set where buttons are. I do believe it's mostly for like, calling a server to decide what text to out where

The div stuff is probably cruft, the sort of thing that could be removed but people don't because it might cause an issue that they wouldn't be able to catch because of all the different places html has to render

2

twovests wrote

ah that makes sense

it feels cursed to say, but i guess html and css are to modern webdevs as bytecode are to other devs? i assume the compiler or JIT magic is trying to cut as much fat as possible, but i've rarely ever touched a compiled output

5

flabberghaster wrote

I remember a few years ago when I was still reading all the programming blogs people kept asking, why are there seven million different javascript frameworks and eight trillion build systems etc.

And the answer to me seemed like, there's just a lot of web devs out there doing not that complex of jobs and they're not feeling challenged and they want to make something more complex and challenging, so they make a framework. And other web devs see it and think it looks cool and want to try something new so they use it. Then it becomes the flavor of the month and if you're not using it you're being left behind. This cycle then repeats.

I sort of think the same thing is going on. You could just do the CSS shit but that's kinda... Not demonstrating new skills. Not something to talk about to show that you're excelling in your field.

5

emma wrote

Every <div> you add increases your hourly salary by $1.

But really, it's frameworks that do this. I use Material UI at work, and the simple login page I did for the project I'm working on now has six nested <div>s just for simple positioning of buttons when using MUI's layout components. In comparison, the latest versions of Postmill, where I did all the HTML/CSS from the ground up, has a maximum of four nested <div>s in direct succession.

3

voxpoplar wrote (edited )

div is a p cool guy

2

flabberghaster wrote

I remember a few years ago when I was still reading all the programming blogs people kept asking, why are there seven million different javascript frameworks and eight trillion build systems etc.

And the answer to me seemed like, there's just a lot of web devs out there doing not that complex of jobs and they're not feeling challenged and they want to make something more complex and challenging, so they make a framework. And other web devs see it and think it looks cool and want to try something new so they use it. Then it becomes the flavor of the month and if you're not using it you're being left behind. This cycle then repeats.

I sort of think the same thing is going on. You could just do the CSS shit but that's kinda... Not demonstrating new skills. Not something to talk about to show that you're excelling in your field.