jQuery vs document.querySelectorAll

后端 未结 12 1061
闹比i
闹比i 2020-11-28 01:28

I heard several times that jQuery\'s strongest asset is the way it queries and manipulates elements in the DOM: you can use CSS queries to create complex queries that would

12条回答
  •  抹茶落季
    2020-11-28 01:50

    In terms of code maintainability, there are several reasons to stick with a widely used library.

    One of the main ones is that they are well documented, and have communities such as ... say ... stackexchange, where help with the libraries can be found. With a custom coded library, you have the source code, and maybe a how-to document, unless the coder(s) spent more time documenting the code than writing it, which is vanishingly rare.

    Writing your own library might work for you , but the intern sitting at the next desk may have an easier time getting up to speed with something like jQuery.

    Call it network effect if you like. This isn't to say that the code will be superior in jQuery; just that the concise nature of the code makes it easier to grasp the overall structure for programmers of all skill levels, if only because there's more functional code visible at once in the file you are viewing. In this sense, 5 lines of code is better than 10.

    To sum up, I see the main benefits of jQuery as being concise code, and ubiquity.

提交回复
热议问题