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