resourceloader: Restore the comment about <script> vs XHR loading
authorBartosz Dziewoński <matma.rex@gmail.com>
Wed, 13 Feb 2019 13:21:04 +0000 (14:21 +0100)
committerKrinkle <krinklemail@gmail.com>
Thu, 14 Feb 2019 00:35:30 +0000 (00:35 +0000)
Removed in 42956b99b558294e5aa8c6c0e2a8f18513478022.

I think it's useful to know this rationale (even more so because
the arguments about caching seem no longer correct these days).

Also, add the line about loading progress not being known when
using this method.

(Slightly related to T216034)

Change-Id: I81fa90483c0c85fecc5cb620196521ce8bdd33a7

resources/src/startup/mediawiki.js

index b5ba6a6..65cf316 100644 (file)
                         * @param {Function} [callback] Callback to run after request resolution
                         */
                        function addScript( src, callback ) {
+                               // Use a <script> element rather than XHR. Using XHR changes the request
+                               // headers (potentially missing a cache hit), and reduces caching in general
+                               // since browsers cache XHR much less (if at all). And XHR means we retrieve
+                               // text, so we'd need to eval, which then messes up line numbers.
+                               // The drawback is that <script> does not offer progress events, feedback is
+                               // only given after downloading, parsing, and execution have completed.
                                var script = document.createElement( 'script' );
                                script.src = src;
                                script.onload = script.onerror = function () {