locked
Should I use Js instead of Jquery when it is possible considering performance issues RRS feed

  • Question

  • User283528319 posted

    hi all,

    I use 

    document.getelementbyId("myinput").value instead of ("#myinput").val()

    because eventhough it doesn't take so much still using Jquery instead of js feels like I waste some little resources.

    what do you think?

    Wednesday, August 7, 2019 1:57 PM

Answers

  • User-719153870 posted

    Hi fatihbarut,

    As far as i know, JS is a scripting language with its own variables and methods. It is mainly used for form validation, interaction with users and dynamic effects, with powerful functions.

    But sometimes it's troublesome to use, so there's the jQuery framework. It is to encapsulate the common methods of JS to form its own structure. Need to load the jQuery library when you use it. With jQuery, you can do more with less code.

    Please refer to Here, you can see detail about the difference between JS and jQuery inclucing the performance.

    Best Regard,

    Yang Shen

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, August 8, 2019 1:49 AM

All replies

  • User-474980206 posted

    they are not exactly the same. if "myinput" is not found, the getElementById().value ttrows an error, while the jQuery version returns undefined.

    I seldom use jQuery anymore, but when I do, I like the consistency of the same api (readability) over performance.

    if you switch to vanilla js, then use document.getElementById, document.querySelector() and fetch instead of $.ajax()

    note: jquery is most helpful if you still support old browsers.

    Wednesday, August 7, 2019 2:28 PM
  • User-719153870 posted

    Hi fatihbarut,

    As far as i know, JS is a scripting language with its own variables and methods. It is mainly used for form validation, interaction with users and dynamic effects, with powerful functions.

    But sometimes it's troublesome to use, so there's the jQuery framework. It is to encapsulate the common methods of JS to form its own structure. Need to load the jQuery library when you use it. With jQuery, you can do more with less code.

    Please refer to Here, you can see detail about the difference between JS and jQuery inclucing the performance.

    Best Regard,

    Yang Shen

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, August 8, 2019 1:49 AM
  • User283528319 posted

    thanks for the link it shows good statistic.

    Thursday, August 8, 2019 4:24 AM