XF 1.2 Where is the best place to add a script?

Stuart Wright

Well-known member
I want to add this script into Xenforo. Probably near the end.
if (!Modernizr.svg) {
$(this).attr('src', $(this).attr('src').replace('.svg', '.png'));
It swaps out SVGs with PNGs for browsers which don't support SVGs.
It uses the Modernizer javascript which I included in the PAGE_CONTAINER template.
I have popped the above code at the end of page_container_js_body, but I'm expecting there is a better way to do this. Like in a hook or something?


Well-known member
Generally, unless you're planning to put it in its own JavaScript file, the page_container_js_body template is the best place to put it in my opinion.


XenForo moderator
Staff member
The FAQ in my signature explains where to add it, depending on the requirements of the script.