XF 2.2 Custom BB media site JS

El Porcharo

Well-known member
I have added a custom media site for embedding staff videos.
The embedding code comes with a javascript tag, which is calling the video hosting service engine.

I have noticed that this impacts quite much on the Page Speed but, since these videos are not embedded everywhere but on some threads only, is there any way to make this JS load only within threads where the code is embedded, or at least just on the thread view template?

This is the media embed code I've set up:

Code:
    <div class="bbMediaWrapper">
        <xf:js src="https://embed.voomly.com/embed/embed-build.js"/>
        <div class="voomly-embed" data-id="{$id}" data-ratio="1.7" data-type="v"></div>
    </div>
 
Last edited:

El Porcharo

Well-known member
Seems like I found a solution on my own.

I moved the script tag to a new template modification for PAGE_CONTANER, that was then configured as follows:

FIND
Code:
</head>

REPLACE
Code:
    <xf:if is="{$template} !== 'forum_list'">
        <xf:js src="https://embed.voomly.com/embed/embed-build.js"/>
    </xf:if>
</head>
 

El Porcharo

Well-known member
Paul, did you mean something like this?

REPLACE
Code:
    <xf:if is="{$template} == 'thread_view' OR 'thread_view_type_article' OR 'thread_view_type_poll' OR 'thread_view_type_question' OR 'thread_view_type_suggestion'">
        <xf:js src="https://site.com/script.js"/>
    </xf:if>
</head>
 

El Porcharo

Well-known member
Thanks buddy, I'll edit that way.

I am rather unfamiliar with PHP, I know just a very little of unuseful basics... So I went for the !== 'forum_list' also because I'm probably going to forget about this modification, so I wouldn't have issues in case of new thread types in future :)

Cheers!
 
Top