Challenge #10 – How Low Can You Limbo

14 March 2023 Open Twig Intermediate

The Limbo World Cham­pi­on­ships have called you in to optim­ise their score­board for performance.


On inspect­ing the homepage, you notice that it is sub­op­tim­al, execut­ing 62 data­base quer­ies and pop­u­lat­ing 28 ele­ments, when you can plainly see that only 18 unique ele­ments are actu­ally dis­played on the score­board. Also, as the num­ber of com­pet­it­ors increases, so do the num­ber of quer­ies and ele­ments, mean­ing that the code has a com­plex­ity of O(n).


There’s no time to lose. Your task is to bring the com­plex­ity of the quer­ies under con­trol and reduce the num­ber of data­base quer­ies executed and ele­ments loaded as much as humanly pos­sible. There have been mur­murs in the limbo com­munity of a rising star that has man­aged to achieve the coveted 35 (data­base quer­ies), but this is yet to be confirmed.

This Git­Hub repo con­tains the Craft CMS site that you can spin up with a single com­mand, either loc­ally or in the browser using a Git­Hub codespace (see the readme file in the repo). Once you are set up, log into the CP as the admin user, vis­it the front-end URL, open the debug tool­bar and then get to work!


Your solu­tion should con­sist of an optim­ised ver­sion of the templates/index.twig tem­plate, along with men­tion­ing the num­ber of data­base quer­ies executed and ele­ments loaded.

  • Cach­ing may not be used. 
  • You may only edit the templates/index.twig template. 
  • You may over­ride the body block, but doing so shouldn’t be neces­sary or even helpful.
  • You must be logged in as the admin user with the debug tool­bar enabled.
  • No plu­gins or mod­ules may be used except for the Ele­ments Pan­el plu­gin, which is and must remain installed.


Eager-load all the things and lever­age Twig fil­ters to help avoid queries.



Submissions will be closed on 14 April 2023 at 23:59:00 CEST.

Submit A Solution