XF 2.2 Page Speed complaining about "Avoid document.write()"

Frode789

Well-known member
What is using this? Core XF? Addon? Not sure where this it is coming from. All I can see it it says ":1116:40". I can't see anything on page source line 1116 that says anything of relevance.
 
Solution
XF uses document.write if you specify loading jQuery from a remote source.

Loading jQuery from a remote source is generally not useful anymore so you could load it locally instead.

I‘m not sure about it being used in Froala, I would have to check, but this warning will only show on the page where it is used. So if you’re running Lighthouse on your forum list (which doesn’t use Froala) and it is appearing then it is likely output by us for the reason I mentioned previously.
XF uses document.write if you specify loading jQuery from a remote source.

Loading jQuery from a remote source is generally not useful anymore so you could load it locally instead.

I‘m not sure about it being used in Froala, I would have to check, but this warning will only show on the page where it is used. So if you’re running Lighthouse on your forum list (which doesn’t use Froala) and it is appearing then it is likely output by us for the reason I mentioned previously.
 
Solution
Load jQuery locally only, this usually does give better performance than loading it off Google or jQuery CDN.

Loading jQuery from a remote source is generally not useful anymore so you could load it locally instead.
Maybe the phrasing should indicate this?

"You may host this yourself (Local) or use one of the recommended CDN sources." may lead users to think that using one of the CDN options is actually recommended.

Smth. like "This setting is deprecated and will be removed in the future. Only enable one of the CDNs if you know exactly what you are doing" might work wonders ;)
 
Last edited:
Yes XF uses jQuery.

We should only load it once though.

Do you have something installed - either on the server side or running as an XF add-on - that attempts to optimise your page HTML/CSS/JS? Perhaps deferring the JS from the head to the body? XF already does this so it is not needed. It’s actually moving the calls to load jQuery and the other JS to after the document.write bit which is a fallback in case jQuery doesn’t load but that should be after we attempt to load it, not before, so it is always loading jQuery twice.

Please report this to the author/developer if applicable.

But ultimately just switch to locally hosted to solve this.

Maybe the phrasing should indicate this?
There are changes coming in a future version.
 
Back
Top Bottom