Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Collapsing menu Re-appearing

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #177234
    Jtwa11
    Participant

    I only have a couple lines of jQuery.

    I want the menu to disappear when window size is less then 750, if you click the logo div, then the menu reappears. However, if you re-size the window to become greater than 750, the menu should reappear.

    I’m trying to make a collapsing menu. I’m not sure if I’m doing it right.

    CodePen

    #177235
    nixnerd
    Participant

    You need to use a media query. That’s done in the CSS. No need for JS here… especially not jQuery.

    #177282
    nixnerd
    Participant

    I was talking to senior developer at MTV and he told me I should be using jQuery. It’s very light weight and makes everything easier, even if it’s for a simple task.

    I couldn’t disagree with this more. jQuery is pretty enormous. I only use it if there is some other tool that I need that already uses it. I figure if I don’t want to re-write a certain plugin and I’m requesting jQuery anyway… why not use it for SOME THINGS? However, if you look at any benchmarks vs. vanilla JS, you will see that it is the clear loser in many, many categories. Almost all. There was a time when it was the glue that held everything together because of browser inconsistencies. These are largely gone or greatly minimized now.

    It’s all about the right tool for the job. I know, you’ve hear it 1 billion times. But… to use jQuery for everything is probably not the best idea. Why don’t you look at the size of MTV’s website. You’ll soon realize there’s nothing lightweight about it. So, it should come as no surprise that they over-use jQuery. Just like people who install WordPress just so they can have a blog and “easily update photos.”

    I just don’t see the need to use one more abstraction layer that you don’t need. You currently have like 4 lines of jQuery. Why would you want a bloated library with features you don’t need, that requires an additional, external server call? It’s not worth it in your case.

    Look at benchmarks vs. vanilla JS. They look at animation benchmarks against GSAP. Plot summary: jQuery pretty much gets killed.

    Do I hate jQuery? No. I just use it sparingly and only when it’s appropriate.

    #177283
    nixnerd
    Participant

    Regarding using media queries, how would I achieve the same results as my codepen?

    There are a few ways. Read here:

    https://css-tricks.com/css-media-queries/

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.