Reassign jQuery to plain old javascript - is it high performance?

Since jQuery is an incredibly simple and commonplace library, I quickly developed a rather complicated project. The entire interface is based on jQuery, and memory is regularly cleaned to maintain optimal performance. Everything works very well in Firefox, and especially in Chrome (I am not interested in other browsers, since this is not a commercial or public product).

Now I'm wondering, since pure, simple, commonplace JavaScript is not really a difficult language to learn, would it be better to rewrite all of this in plain old JavaScript, and if so, what kind of impetus do you expect from this?

If the answers are positive enough, I will continue and do it, run the test and send a report with accurate results.

Edit: Thanks guys, valuable insight. The goal was not to “reinvent the wheel” - it was just for experience and personal improvement. Just because something exists does not mean that you should not examine it in more detail, know how it works or try to recreate it. This is the same reason that I rarely use frameworks, I would rather use my own code and smooth it out and get a lot of experience in this, rather than starting with using another code, no matter how it smooths it. In any case, I will not do this, thanks for saving me the effort :)

+4
source share
4 answers

You say that the site works from "very good" to "exclusively" - then do not worry. It will not be worth the effort, and there is no guarantee that your end result will be even more optimal than with jQuery, since the jQuery team can fix many problems for many years.

You also say that plain old JS “really not complicated language” is not the main problem. This is not JS, which is difficult to master, and what compensates for jQuery, but all the different features of the browser.

In the end, even if you create a site that will be slightly faster without jQuery, you have one that is much more difficult to maintain.

In short, there are times when such an exercise is valuable, but not when your site is already working "very well", and it is not necessarily as simple as you think.

+7
source

Do not worry.

Of course, you can get some performance using vanilla js, and in some versions it is worth it, but overall, just as you use jQuery well, your gains from vanilla js are small, and the loss of cross-browser support is not.

Why reinvent the wheel?

If you want to polish your implementation, find places where you can store and reuse references to DOM elements, so you don't need to go through the DOM every time you need to use them.

+4
source

No.

Sorry, but if you don’t have the same ability as jQuery developers, this might not be a good idea .

Yes, you can cut some code that will not be used, and you might even get a little performance . But if you are not so skilled, you will probably find yourself missing out on a lot of improvements. the team is implemented and will not even get speed.

The biggest reason people prefer jQuery over JavaScript is development speed , support, and cross-server compatibility . You risk losing it all.

  • Higher-level code means faster development, but also faster support in the future. Finding and fixing errors in higher-level code is easier.
  • JQuery code will be updated by the team when new problems are discovered or new browsers appear. You will have to duplicate all these changes in your own code.
  • If you encounter an error in your own code, you yourself . If you are having difficulty with jQuery scripts, there is a huge user base that can help you.
  • And don't start me with all existing plugins . What if tomorrow your client wants you to add the X widget to your site and you don’t have jQuery? Will you also come up with this plugin again?
+4
source

Source: https://habr.com/ru/post/1343730/


All Articles