Topic on Project:Support desk

DOM loading stuck on MediaWiki

4
Rbirmann (talkcontribs)

Hi, I am using MW 1.34.2 and have been having some issues with custom Javascript code.

In one os my scripts I need to run some code after the page is loaded, so I use document.addEventListener("DOMContentLoaded",myFunction, false);. However, the DOMContentLoaded event never gets triggered. Using Chrome Dev Tools to "watch" document.readyState, I noticed it never leaves the 'loading' stage.

This property can be 'loading', 'interactive' or 'complete' and (I recently learned that) once it gets to 'complete' the DOMContentLoaded is triggered. The "loading" wheel on my Chrome tab stops spinning and all content on the page seems to be in place, but document.readyState is still stuck in 'loading'. Something is preventing completion of the loading process, thus causing my scripts to never run.

(Actually, sometimes document.readyState eventually turns to 'complete', but it takes several minutes, so it might be something timming out, instead of failing... not sure).

I have tried changing my skin and disabling all my custom scripts, to no avail.

There are some errors / warnings on my console after loading any page on the wiki. From what I was able to figure out (googling) they do not seem to be the issue, but still, here is the output:


P%C3%A1gina_principal:1 Unchecked runtime.lastError: The message port closed before a response was received.
 P%C3%A1gina_principal:1 Unchecked runtime.lastError: The message port closed before a response was received.
 P%C3%A1gina_principal:1 Unchecked runtime.lastError: The message port closed before a response was received.
 load.php?lang=pt-br&…s&version=1j8oy:144 JQMIGRATE: Migrate is installed with logging active, version 3.0.1
 VM97:105 This page is using the deprecated ResourceLoader module "jquery.tabIndex".
 P%C3%A1gina_principal:1 Mixed Content: The page at 'https://www.mydomain.com/wiki/P%C3%A1gina_principal' was loaded over HTTPS, but requested an insecure favicon 'http://www.mydomain.com/wiki/Favicon.ico'. This request has been blocked; the content must be served over HTTPS.
 P%C3%A1gina_principal:1 The resource https://www.mydomain.com/w/logo_wiki.png?bda1e was preloaded using link preload but not used within a few seconds from the window's load event. Please make sure it has an appropriate `as` value and it is preloaded intentionally.

Any thoughts will be greatly appreciated.

Thanks in advance


Bawolff (talkcontribs)

The Unchecked runtime.lastError: The message port closed before a response was received is kind of weird sounding and one i havent heard of before. I would investigate that one.

I would check network tab to see if any connections are just sitting there waiting.

It sounds like it could be some sort of weird misconfiguration between http/2, content-length headeds and gzip - bit of a long shot but check if $wgDisableOutputCompression affects anything. I would check config related to those things generally. Also try loading a page with curl -v to see if it gives any warnings (sometimes curl is better at giving warnings than web browsers)

Rbirmann (talkcontribs)

Thanks @Bawolff!! The tip of checking the Network tabs was very useful. In my case, my antivirus software (Kapersky) was injecting a script in all pages and that script never loaded, preventing the document loading to complete. I have disabled JS injection from Kapersky altogether (too bad they only have a global settings instead of a whitelist option) and now my scripts fire normally.

It is still odd however that the injected script doesn't seem to be causing any other sites to halt. At least I wasn't able to notice it anywhere else. Not even Wikipedia or other MediaWiki sites.

Bawolff (talkcontribs)

If your site is http and not https, it might only be injecting into http sites or something like that.

Reply to "DOM loading stuck on MediaWiki"