jQuery to vanilla

Alisa Bonjour 6 Reputation points
2021-08-16T14:33:48.113+00:00

Did anyone came across migrating from jQuery to vanilla js in ASP.net. If so please let me know is there any tool or converter for migration. Any suggestions are welcomed. Please guide me what all needed to work on vanilla js.Is there any plugins or script file that can be downloadable and use it.Also please clarify is vanilla js and JavaScript both are same

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,612 questions
{count} vote

2 answers

Sort by: Most helpful
  1. George A. Johnson 1 Reputation point
    2022-02-14T14:05:37.79+00:00

    I need the same help with migrating from jQuery to vanilla js in ASP.net

    0 comments No comments

  2. Bruce (SqlWork.com) 66,706 Reputation points
    2022-02-14T17:36:54.61+00:00

    yes vanilla js is just javascript and so is jQuery.

    jQuery was created during a time when browser dom api's varied a lot (especially IE), and jQuery was a common api to dom. as the browser matured and IE died, there is no a more common robust api. vanilla.js refers to using the new dom api directly rather than a wrapper.

    jQuery focused on couple apis:

    1) dom node lookup. jQuery supported css selectors for finding nodes. document.querySelector() offers similar functionality
    2) dom events. node.addEventListener() offerer similar but limited features. use dispatchEvent instead of trigger
    3) css attributes. you can lookup class nodes with query selectors and update the properties directly.
    4) add and remove classes from elements. this is now simple with .classList api.
    5) create dom elements. the createElement() api is much more standard now.
    6) ajax. use fetch instead

    there is no replacement for jQuery's plugin support for building components.

    cheatsheet:

    https://tobiasahlin.com/blog/move-from-jquery-to-vanilla-javascript/

    manually converting the code will teach you the dom api and tell you if its worth it.

    if you google you will find some tools that will convert snippets of jQuery. but jQuery went beyond the dom api, and there are no replacements for this.

    note: in general there is typically not a good reason to port jQuery code to vanilla.js. this is a decision to be made at the start of the project.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.