This is a quick best practice tip and what will most likely become an involved discussion around ids for XPages controls.
I had to think carefully before posting this, but decided to do so as I know it would prove beneficial to the online community either way.
One of the recent items I’ve added to my “best practices” list, is to not use ids for XPages controls that do not require it. A great example of this are label controls. 99.9% of the time, I require no programmatic handle on any of my label controls. What most should know by now is that if you assign an id of “label1” to the label control, this id gets converted to something along the lines of “view:_id1:_id2:_id11:label1” when the HTML page gets rendered to the user. I’m hoping by now you start understanding my concern?
Let’s say you had about 20 controls that make up your XPage that don’t require ids….that’s at least about 500 bytes of data the user has to download just for these id names. NOTE: This is before compression has taken place. (This could be 100 bytes after compression is applied)
See below example XPage. All it contains (other than the defaults that Domino provides) is 20 label controls with an id name of “label1“. The size of the HTML page is 633 bytes (post compression).
See below 2nd example of the same XPage, except there are no ids assigned to these 20 labels. The size of the HTML page is 567 bytes (post compression).
For most of you (i’m guessing), the difference in size is probably too small to action, but for me, it forms part of a drive to deliver the best online, mobile and browser experience possible to my clients and users.
Ok people, bring on the discussions….I’m ready!!