V3NTUS
Well-known member
So uhm, while browsing some add-ons I installed, I found this code in one of its templates:
I thought it was wrong at first, as I couldn't find any documentation related to it. All these years, if I had an external javascript file to include, I just used to do:
Or
But I never really thought about merging them. Any performance advantages in wrapping the script within xf:js tags? Also, assuming the javascript file isn't external, what would be the recommended way to load it, if I'd like to defer, async load it but also combine it? Would something like this work?
Thank you.
I thought it was wrong at first, as I couldn't find any documentation related to it. All these years, if I had an external javascript file to include, I just used to do:
<script async defer src="https://example.com/script.js">
</script>
Or
<xf:js src="https://example.com/script.js" />
But I never really thought about merging them. Any performance advantages in wrapping the script within xf:js tags? Also, assuming the javascript file isn't external, what would be the recommended way to load it, if I'd like to defer, async load it but also combine it? Would something like this work?
<xf:js async defer src="https://mywebsite.com/script.js" />
Thank you.
Last edited: