FANDOM


This article is a guide on code installation around FANDOM.

CSS imports on FANDOM

On FANDOM, the CSS @import can efficiently import a collection of stylesheets to:

  • minify them and increase performance
  • look cleaner
  • cache consistently

Consider the examples below.

Examples of @import usage

On the left there is an example of several imports using the classic @import rule. On the right is how you can merge them in a single command, which will minify them, thus increasing performance:

Multiple imports — messy and slow

  1. @import url("/index.php?title=MediaWiki:LocalCSS1.css&action=raw&ctype=text/css");
  2. @import url("/index.php?title=MediaWiki:LocalCSS2.css&action=raw&ctype=text/css");
  3. @import url("http://dev.wikia.com/index.php?title=MediaWiki:InterWikiCSS.css&action=raw&ctype=text/css");
  4. /* CSS */

One import — clean and efficient

  1. @import url("/load.php?mode=articles&only=styles&articles=MediaWiki:LocalCSS1.css|MediaWiki:LocalCSS2.css|u:dev:MediaWiki:InterWikiCSS.css");
  2. /* CSS */

Placement of CSS @import rules

CSS imports rules must be stated at the beginning of the page, before any other rule. Otherwise they won't work. Here's an example of the correct placement:

Wrong placement

  1. /* CSS */
  2. @import url("/load.php?mode=articles&only=styles&articles=MediaWiki:LocalCSS1.css|MediaWiki:LocalCSS2.css|u:dev:MediaWiki:InterWikiCSS.css");

Correct placement

  1. @import url("/load.php?mode=articles&only=styles&articles=MediaWiki:LocalCSS1.css|MediaWiki:LocalCSS2.css|u:dev:MediaWiki:InterWikiCSS.css");
  2. /* CSS */

It's also possible to import CSS using JavaScript pages through importArticles (read more).

JavaScript imports on FANDOM

The importArticles statement is designed to efficiently batch import scripts:

  • to speed up performance,
  • make your code look cleaner,
  • combine multiple HTTP requests into a single data transfer,
  • and allow multiple scripts to load and execute faster

If you've been installing several different scripts, your JavaScript file has probably accumulated unnecessary import statements.

Examples of importArticles usage

If your JavaScript file has several lines of code that say importScript, importScriptPage, or importArticles, you may be able to combine them! Consider the example below. On the left is an example of what your JavaScript file might currently look like. On the right is how you could improve that code.

Multiple imports — messy and slow

  1. importScriptPage('Script1.js', 'dev');
  2. importScript('MediaWiki:Script2.js');
  3. importArticle({
  4.   type: 'script',
  5.   article: 'u:dev:Script3/code.js'
  6. });
  7. importScriptPage('Page1.js', 'wiki');
  8. importScriptPage('Page2.js', 'wiki');

One import — clean and efficient

  1. importArticles({
  2.     type: 'script',
  3.     articles: [
  4.         'u:dev:Script1.js',
  5.         'MediaWiki:Script2.js',
  6.         'u:dev:Script3/code.js',
  7.         'u:wiki:Page1.js',
  8.         'u:wiki:Page2.js'
  9.     ]
  10. });

Notes about importing JavaScript

Note: In this example, pay close attention to the placement of commas and other punctuation. For people who aren't familiar with programming (and even those who are!), a common mistake when writing code is to accidentally delete, forget, or misplace critical symbols like commas or quotation marks. This can cause a syntax error that breaks the code. Carefully follow the convention shown here when using importArticles.

One other approach is by using MediaWiki:ImportJS. But there's much more to importArticles than just this!

HTML and wikitext markup on FANDOM

Location Source

How to switch to source mode and make your code look cleaner.

Source mode is designed to handle complex HTML codes on an article, allowing to reduce the amount of unwanted code that is sometimes automatically added. Source mode is the best way to edit if you are using templates, or HTML tags such as <span>, <p>, and <div>.

Here are some useful tips:

  • When you see Double Brackets Icon in the edit area of visual mode, it refers to a template, or content with code that is not supported or too complex for the visual editor to handle. In source mode you will see this content in full.
  • When you see Comment Icon in the edit area of visual mode, it refers to a comment. In source mode, you will see this content as <!-- -->.
  • MediaWiki has a special language called wikitext to make editing easier. This language is supported in visual mode and will not break as easily as HTML.
  • Some HTML tags like <u> or <s> are supported in visual mode.
  • You can also enter source mode when creating or replying to threads in a forum, or when using a message wall by clicking Comment Source Modus underneath the edit area.
  • You can edit templates in source mode only.

See also

Text above can be found here (edit)