Why is jQuery selector function so slow compared to native DOM methods

后端 未结 3 1810
既然无缘
既然无缘 2020-12-31 08:01

I know this topic has been debated in general several times already, but I am looking for a more technical and detailed insight to understand what is really going on.

<
3条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-31 08:47

    This is the amount of code jquery goes through when we use a simple $('selector')

    http://james.padolsey.com/jquery/#v=1.10.2&fn=init

    As you can see,there are plenty of validation done,regex matches,cross browser tricks etc.

    Its important to realise that jquery is a library built on javascript.Javascript executes directly on the browser.Where as jquery processes quite a lot of javascript code before being executed by the browser.

    I personally prefer jquery.I am really not bothered about saving those nano seconds.The level of simplicity that jquery provides is phenomenal and an artpiece in itself.

提交回复
热议问题