Topic on Talk:Talk pages project/Replying/Flow

Repeated page-load events in Source mode

10
RoySmith (talkcontribs)

When you switch to Source mode, it looks like the page is getting extraneous javascript events as you type. For example, on enwiki, put this in your common.js:

mw.loader.load('https://tools-static.wmflabs.org/spi-tools-dev/spi/tag-check.js');

maxUsersCUStaleness = 300;

mw.loader.load("/w/index.php?title=User:Writ Keeper/Scripts/cuStaleness.js&action=raw&ctype=text/javascript");

mw.loader.load("/w/index.php?title=User:Writ Keeper/Scripts/sockStaleness.js&action=raw&ctype=text/javascript");


These are three scripts commonly in use by SPI clerks. Now, navigate to an SPI page (say, :en:Wikipedia:Sockpuppet investigations/Jinnifer, reply to a comment, go into Source mode, and start typing. The scripts will run repeatedly every keystroke or so, as seen in the attached screenshot.

Tacsipacsi (talkcontribs)

This is exactly what I was worried about in phab:T279141#6986316. I don’t know how exactly these scripts work, but users of the wikipage.content hook should rely on, and only on, the hook parameter; they should not use global queries (e.g. $('.myClassname')), only those that work with the content passed by the hook (e.g. $content.find('.myClassname') or $('.myClassname', $content)).

RoySmith (talkcontribs)

My javascript skills are pretty much in the "knows just enough to be dangerous" category, so yeah, I was relying on global queries, i.e.

$("span.cuEntry a[href*='/User:']").each(async function() {...}

in my wikipage.content hook. Thanks for the suggestion. I pinged the author of the other script here too :-)

Pelagic (talkcontribs)
RoySmith (talkcontribs)
Matma Rex (talkcontribs)

It looks like all of the problems reported so far have been fixed:

https://tools-static.wmflabs.org/spi-tools-dev/spi/tag-check.js

I don't know where to check the revision/commit history, but the code looks like it should handle this correctly now, I assume you fixed it RoySmith? Thanks!

Fixed by the author:

(Not in the ideal way – the scripts no longer use the hook, and won't run again after page content is updated without reloading – but whatever…)

w:en:Wikipedia talk:Talk pages project#Performance with blocked username gadget

Fixed by me: https://en.wikipedia.org/w/index.php?title=MediaWiki:Gadget-markblocked.js&diff=1032763221&oldid=1021641704

en:WT:HotCat#Doubled HotCat insertions with Reply Tool

Fixed by me: https://commons.wikimedia.org/w/index.php?title=MediaWiki:Gadget-HotCat.js&diff=574182738&oldid=568234975 (although this one was not related to the use of wikipage.content hook).

RoySmith (talkcontribs)
Matma Rex (talkcontribs)
Matma Rex (talkcontribs)
RoySmith (talkcontribs)

Oh, how embarrassing :-)

Reply to "Repeated page-load events in Source mode"