Various javascript optimizations (fixes bug 39959)
authorTimo Tijhof <ttijhof@wikimedia.org>
Tue, 4 Sep 2012 19:47:20 +0000 (21:47 +0200)
committerDerk-Jan Hartman <hartman@videolan.org>
Tue, 4 Sep 2012 21:56:38 +0000 (23:56 +0200)
commitc9ba56de4883800f7ae937351e59aaf2d97f1623
tree0603cd85e5a211b9e31b18b5a094f960312a71ed
parente4ab0f83db3126ab02efbd02e8210e45fe6a8e77
Various javascript optimizations (fixes bug 39959)

* (bug 39959) Right click to edit section causing browser hangs

  The :has() selector has gotten significantly slower in
  jQuery 1.8.1 however the reason it affected us so much is
  partly because of the very inefficient way we used it.

  Namely duplicated 6 times and evaluated from a live() binding
  In order words, on every instance of the event.

  Optimizing by
  - only select headings, do the :has implicitly by checking
    for the result of .find().
  - document.on(.., selector) instead of .live()
  - remove redundant and overkill 'return false'

  Results in Firefox 15/Chrome 21:
  - up to 130x (one hundred and thirty) faster!

* /resources/* (except for third party libs)
  - Use .on() instead of bind, delegate or live
  - Use .off() instead of unbind, undelegate or die
  - Use document.getElementById instead of $('#' + variable)
    not for performance but for predictability/security.
    (e.g. rel="foo.bar" should select id="foo.bar" not
    id="foo" class="bar")

  - Fix some minor whitespace and code conventions.

Change-Id: I2fefb5376d0de40f4997a3a1763eee23fcd3e7fa
resources/jquery/jquery.makeCollapsible.js
resources/jquery/jquery.placeholder.js
resources/mediawiki.action/mediawiki.action.view.rightClickEdit.js
resources/mediawiki/mediawiki.htmlform.js
skins/common/config.js