Jump to content

User talk:SD0001/Making user scripts load faster

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Qwerfjkl (talk | contribs) at 16:55, 15 June 2021 (Conflict with scriptManager: Reply). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Further issue with spihelper

This script seemingly does not work with spihelper again. It worked for a bit, but now does not work again. The error from the console is "Uncaught (in promise) ReferenceError: displayMessage is not defined". This seemingly seems to be the script not working well with importing scripts from cached scripts. The displayMessage function is in a imported javascript file in spihelper. When adding "?nocache=yes" to the URL it does not cause the error. I also manually called "displayMessage" with and without the cache and confirmed that with cache the javascript console does not have the function defined. However, the network tab shows that regardless of cache being enabled or not enabled the displayMessage javascript file is still downloaded or has loaded the cached result (and using the api method if caching is enabled). I'm using Firefox. Dreamy Jazz talk to me | my contributions 22:07, 3 June 2021 (UTC)[reply]

@Dreamy Jazz Thanks for the note. Just seeing this now. Should be fixed. I replaced use of eval with inserting a <script> tag, which seems to make the behaviour more like the uncached method.
Going by the book, if User:Timotheus Canens/displaymessage.js wants displayMessage to be globally exposed, it should really be doing window.displayMessage = function() {...}. I'm surprised that it even works. – SD0001 (talk) 16:55, 13 June 2021 (UTC)[reply]

Conflict with scriptManager

@SD0001: I think this has a conflict with scriptManager, meaning it ignores scriptManager-installed scripts. Also, the text to be copied and pasted could be replaced with {{subst:User:SD0001/userscript-load-caching.min.js}} and {{subst:User:SD0001/userscript-load-caching.js}}, respectively. ― Qwerfjkl | 𝕋𝔸𝕃𝕂  (please use {{reply to|Qwerfjkl}} on reply)Template:Z181 13:56, 13 June 2021 (UTC)[reply]

@Qwerfjkl I made some changes per the above section. Could you check again? Looking at scriptManager's source code, I can't think of a reason why the two would conflict. Also, does it now work with RedWarn? – SD0001 (talk) 11:55, 15 June 2021 (UTC)[reply]
@SD0001 We now just need Ed6767 to apply the changes to User:RedWarn/.js. ― Qwerfjkl | 𝕋𝔸𝕃𝕂  (please use {{reply to|Qwerfjkl}} on reply)Template:Z181 15:55, 15 June 2021 (UTC)[reply]
@SD0001 With scriptManager enbled I get this error:
mdlLogic.js:1 Uncaught URIError: URI malformed
at decodeURIComponent (<anonymous>)
at Function.t.EPPyTH (mdlLogic.js:1)
at t (mdlLogic.js:1)
at Object.mw.loader.load (<anonymous>:3:767)
at HTMLAnchorElement.loadScript (index.php?action=raw&ctype=text/javascript&title=User%3AMusikAnimal%2FscriptManager.js:15)
at HTMLAnchorElement.dispatch (load.php?lang=en&modules=jquery%2Coojs-ui-core|jquery.ui&skin=vector&version=1a0i7:70)
at HTMLAnchorElement.elemData.handle (load.php?lang=en&modules=jquery%2Coojs-ui-core|jquery.ui&skin=vector&version=1a0i7:66) ― Qwerfjkl | 𝕋𝔸𝕃𝕂  (please use {{reply to|Qwerfjkl}} on reply)Template:Z181 15:59, 15 June 2021 (UTC)[reply]
@Qwerfjkl I just tested with both (scriptManager & RedWarn) and they all work fine for me now. The changes to User:RedWarn/.js are already applied.
As to why it isn't working for you, it might be because of complications in your common.js. You can remove those if (scriptManager == ...) conditions now as scriptManager and script caching wouldn't conflict. Also, avoid redefining importScript (lines 4-6) as the script caching code does this internally. – SD0001 (talk) 16:38, 15 June 2021 (UTC)[reply]
@SD0001 I think I've removed all of the unecessary code (messily). ― Qwerfjkl | 𝕋𝔸𝕃𝕂  (please use {{reply to|Qwerfjkl}} on reply)Template:Z181 16:55, 15 June 2021 (UTC)[reply]