dev

PreloadRedLinks adds the preload argument to red links on pages according to rules defined, which can be site-wide or user defined as needed.

Installation

Configuration

The script can be used as it is when used site-wide, but it does also support these customizable variables that can be added before the import on Common.js. Common.js will run before MediaWiki:ImportJS.

Using configuration options with Fandom Developers Wiki scripts

The instructions on this page describe how to use configuration options with a script. Here on the Fandom Developers Wiki, many scripts provide optional configuration settings as a mean to alter or enhance the default behavior of the script. When installing configuration options in your JavaScript file, please note that they need to go above the import statement in order to work — unless the directions say otherwise. In case MediaWiki:ImportJS is used to load the scripts, it will be executed last.

Configuration options load too late, don't work
// 1. AjaxRC import statement
importArticles({
    type: 'script',
    articles: [
        'u:dev:MediaWiki:AjaxRC.js'
    ]
});

// 2. AjaxRC configuration option
window.ajaxRefresh = 30000;
Proper placement of configuration options
// 1. AjaxRC configuration option
window.ajaxRefresh = 30000;

// 2. AjaxRC import statement
importArticles({
    type: 'script',
    articles: [
        'u:dev:MediaWiki:AjaxRC.js'
    ]
});

window.preloadRedLinks_rules

Usage

To use the tool, you have to create the required pages:

Example

Default

Using the default configuration, if on MediaWiki:Custom-PreloadRedLinks we add:

* Template:Preload/version | Version/.+
* Template:Preload/Template doc | Template:.+/doc

With this code, all red links which which is a subpage of Version will come with their preload template created as Template:Preload/version. And all red links of template documents will come with Template:Preload/Template doc.

Equivalent JS function

{{{example-JS-desc|Defining JS functions as the rules can be more flexible and allows more complex rules. As no config page in MediaWiki namespace is needed in this way, the script can be used fully personally (though you have to make sure that the preload templates you use exist).

As an example, the above default rule can be achieved by:

window.preloadRedLinks_rules = function(pagename){
  if (pagename.startsWith("Version/")) { 
    return "Template:Preload/version";
  }
  if (pagename.startsWith("Template:") && pagename.endsWith("/doc")) { 
    return "Template:Preload/Template doc";
  }
  return null
}
Text above can be found here (edit)