#registerEndOfPageHtml() directive

Hello, we tried to use the #registerEndOfPageHtml() directive but it doesn't work to register the scripts on the end of the page - and it gets echoed instead at the bottom.
What am I doing wrong?

I'm going through the docs here: https://community.telligent.com/community/11/w/developer-training/65122/using-ajax#When_should_I_use_JavaScript_in_widgets