XF 2.3 Extend lazy loaded javascript

XFA

Well-known member
Hi,

Now that some part of the javascript is lazy loaded, what would be the best way to extend javascript element handler that are lazy loaded ?

I used to extend the Disabler element but I didn't find the right solution yet.

Any insight would be appreciated.

Thanks,
Clément
 
Not sure it's the best way, but I managed to achieve what I wanted by including my js file like that:
Code:
<xf:js>
XF.on(document, 'xf:page-load-complete', (e) => {
        XF.LazyHandlerLoader.register('my-js-file', 'my-disabler');
    });
</xf:js>
 
Yeah that should be fine, though I don't think it needs to be wrapped in the event handler since inline JS is already auto-wrapped in a DOMContentLoaded handler. If the my-disabler handler is used sparingly/predictably, I'd recommend just using loading the base handler and the extension via <xf:js> instead.
 
I tried without and as the form.js file is loaded later on, the disabler was not yet loaded if not done like that as my js file was loaded beforehand.
 
You would need to require both of them in <xf:js> tags, in which case they should be loaded in order:

HTML:
<xf:js src="xf/form.js" min="1" />
<xf:js addon="My/AddOn" src="my/addon/my-js-file.js" min="1" />
 
Oh right so I would need to explicitely include the form.js beforehand and not let xf lazy load it.

Gotcha, thank you !
 
Back
Top Bottom