Select Page

In our application we provide popup glossary terms and footnotes.  Sometimes a lot of them.  Like 200+ within the same XPage.

When I initially developed that functionality, I did what I always do and tell others to do: Code it the way you’d like to code it and if the performance is good, then leave it like that.

“WHAT?! Code should always be optimized, Russ, and follow style guides and programming conventions and <sputter> <spit>…”

“Code Shmode” is what I say.

Code’s only purpose in life is to produce something useful and if it works great the first time, then it’s good code.


Well, as it turns out, my code wasn’t so good this time but I didn’t really see the problem until we started getting larger sets of data.  In other words, scalability was an issue.

What did I do to fix it?

I got out The Pencil, of course, and recorded page load times using Firebug for various combinations of code blocks.  There were only two blocks of code so it didn’t take long to determine which block was really slowing down the page.  Once I knew that, I modified the code and, Poof!, page load times went from 3.7 seconds down to 1.7 seconds which is a 54% reduction.

For what it’s worth, those load times are with no caching so actual load times average well under 1 second so these results were All Good.

Since I’ve only had to refactor code maybe three times in my career to improve performance I’m gonna’ stick with my general rule but I guess the caveat is to code with performance in mind all the time. XPages performance is pretty darn good in my experience as long as you’re not doing something obviously wasteful aka crazy.

Tomorrow I’ll share the code modifications.