WordPress Trac: Ticket #23473: Performance Improvement in three JavaScript Source Codeshttps://core.trac.wordpress.org/ticket/23473
<p>
By performance profiling in Internet Explorer 10, Firefox 17 and Chrome 25, I found performance improvement in wp-admin/js/post.js, wp-includes/js/media-views.js and wp-includes/js/utils.js. Function clean() at line number 17 in post.js, function set() at line number 98 in util.js and function visibility() at line number 2767 in media-views.js can be improved with same functionality.
</p>
<p>
I measured inclusive execution times of original code and improved code. The image is the result. The machine I used to measure execution times has Intel Core i5 1.6GHz CPU and 4GB RAM.
</p>
<p>
I also attached a patch file.
</p>
en-usWordPress Trachttps://core.trac.wordpress.org/chrome/site/your_project_logo.pnghttps://core.trac.wordpress.org/ticket/23473
Trac 1.0.1yongbaeThu, 14 Feb 2013 02:44:58 GMTattachment sethttps://core.trac.wordpress.org/ticket/23473
https://core.trac.wordpress.org/ticket/23473
<ul>
<li><strong>attachment</strong>
set to <em>graph.png</em>
</li>
</ul>
<p>
Graph of inclusive execution time
</p>
TicketyongbaeThu, 14 Feb 2013 02:45:21 GMTattachment sethttps://core.trac.wordpress.org/ticket/23473
https://core.trac.wordpress.org/ticket/23473
<ul>
<li><strong>attachment</strong>
set to <em>performance.patch</em>
</li>
</ul>
TicketSergeyBiryukovThu, 14 Feb 2013 02:49:28 GMTcomponent changed; keywords sethttps://core.trac.wordpress.org/ticket/23473#comment:1
https://core.trac.wordpress.org/ticket/23473#comment:1
<ul>
<li><strong>keywords</strong>
<em>has-patch</em> added
</li>
<li><strong>component</strong>
changed from <em>General</em> to <em>Performance</em>
</li>
</ul>
TicketscribuThu, 14 Feb 2013 03:00:15 GMThttps://core.trac.wordpress.org/ticket/23473#comment:2
https://core.trac.wordpress.org/ticket/23473#comment:2
<p>
So, all 3 changes amount to less than 1ms in speed, or am I reading the graph wrong?
</p>
TicketyongbaeThu, 14 Feb 2013 03:15:30 GMThttps://core.trac.wordpress.org/ticket/23473#comment:3
https://core.trac.wordpress.org/ticket/23473#comment:3
<p>
You are right.
</p>
TicketscribuThu, 14 Feb 2013 11:23:11 GMTkeywords changedhttps://core.trac.wordpress.org/ticket/23473#comment:4
https://core.trac.wordpress.org/ticket/23473#comment:4
<ul>
<li><strong>keywords</strong>
<em>close</em> added
</li>
</ul>
<p>
Rather than doing micro-optimizations like this with little to no benefit, maybe your time would be better spent fixing all the jQuery deprecation warnings in <a class="closed ticket" href="https://core.trac.wordpress.org/ticket/22975" title="enhancement: Remove deprecated jQuery methods from core to be safe for jQuery 1.9 (closed: fixed)">#22975</a>. Just saying.
</p>
TicketmarkoheijnenThu, 14 Feb 2013 15:20:15 GMThttps://core.trac.wordpress.org/ticket/23473#comment:5
https://core.trac.wordpress.org/ticket/23473#comment:5
<p>
If everything still works as before I don't see any reason why not to commit this. The patch also cleans out the code a bit.
</p>
TicketscribuThu, 14 Feb 2013 15:26:15 GMThttps://core.trac.wordpress.org/ticket/23473#comment:6
https://core.trac.wordpress.org/ticket/23473#comment:6
<blockquote class="citation">
<p>
If everything still works as before I don't see any reason why not to commit this.
</p>
</blockquote>
<p>
So, how about we start randomly refactoring code, just for the hell of it? As long as it doesn't break, it's all good, right?
</p>
TicketmarkoheijnenThu, 14 Feb 2013 15:35:02 GMThttps://core.trac.wordpress.org/ticket/23473#comment:7
https://core.trac.wordpress.org/ticket/23473#comment:7
<p>
We optimize/refactor code pretty often. Like this commit <a class="changeset" href="https://core.trac.wordpress.org/changeset/23410" title="Return from image_downsize() earlier if a custom resize function is used. ...">[23410]</a>. I don't say we should pick random code and just change it. That is bad and I can see that. This patch makes the code a little bit more readable too. But that just my opinion. If it gets closed as worksforme I'm fine with that too.
</p>
TicketscribuThu, 14 Feb 2013 15:57:18 GMThttps://core.trac.wordpress.org/ticket/23473#comment:8
https://core.trac.wordpress.org/ticket/23473#comment:8
<p>
We rarely refactor purely for aesthetic reasons, though. And, as the graph shows, there simply isn't much performance gain.
</p>
TicketGaryJFri, 15 Feb 2013 17:19:29 GMTkeywords changedhttps://core.trac.wordpress.org/ticket/23473#comment:9
https://core.trac.wordpress.org/ticket/23473#comment:9
<ul>
<li><strong>keywords</strong>
<em>close</em> removed
</li>
</ul>
<p>
But, it *is* a performance gain if the graph holds true, the work has already been done, and it's only a dozen or so lines to review for when a committer has got those files at the forefront of their mind. Even my cursory 30-second glance suggest the changes look sensible enough to warrant consideration.
</p>
<p>
Let's not be dismissive of any efforts to contribute, however small or off-topic you think it might be.
</p>
TicketnacinFri, 24 Jan 2014 05:32:28 GMTcomponent changed; focuses sethttps://core.trac.wordpress.org/ticket/23473#comment:10
https://core.trac.wordpress.org/ticket/23473#comment:10
<ul>
<li><strong>focuses</strong>
<em>javascript</em> <em>performance</em> added
</li>
<li><strong>component</strong>
changed from <em>Performance</em> to <em>Administration</em>
</li>
</ul>
Ticket