What real purpose does $.noop() serve in jQuery 1.4?

前端 未结 9 741
故里飘歌
故里飘歌 2020-12-30 19:01

Pouring over the release notes regarding jQuery 1.4, I came acrosss $.noop() which is:

Description: An empty function. (added in 1.4)

9条回答
  •  -上瘾入骨i
    2020-12-30 19:15

    This function was proposed due to performance issues on embedded systems when using $.ajax, reported on the jQuery-Dev mailing list. You can see the thread.

    Basically, they preferred to introduce and use this single empty function, rather than declaring empty anonymous functions all around.

    Now this function is internally used in the ajax, event and offset modules.

    You can give a look to the commit when it was introduced also.

提交回复
热议问题