This help page will explain the recommended ways to include additional CSS and JavaScript on your community.
ImportJS
This new method adds the MediaWiki page MediaWiki:ImportJS and provides an interface for including articles that contain scripts on a community - both local or from Dev Wiki (support for Dev Wiki imports is coming soon).
The functionality is similar to the existing method importArticles
, which can import articles from external communities, bundle several articles into one, minify them and serve them as a single request. This reduces both file size and web traffic, effectively making a community with a large number of additional files load much faster.
Usage
MediaWiki:ImportJS provides a plain text article in which to load JavaScript from. Local files will need to be in the MediaWiki namespace. Dev Wiki imports will also need to be in the MediaWiki namespace to work (support coming soon). When stating files to import, the MediaWiki namespace does not need to be included. Example:
Cat.js //local JS file
dev:AjaxRC.js // Dev Wiki script
Load order
When using ImportJS, the pages within will be loaded last. The full load order is:
- Common.js
- Wikia.js
- Imported scripts through Common.js
- Imported scripts through Wikia.js
- ImportJS
CSS imports
importArticles
In lieu of the above method, importArticles will only be discussed here in regards to CSS imports. For JS imports, please see this page.
importArticles can still be used to import CSS styles. However, they will be subject to JS review since it has to be done through JavaScript.
Example
Importing a local CSS file through importArticles:
importArticles({
type: "style",
article: "MediaWiki:Local.css"
});
@import method
Using the @import
, styles can be imported from any CSS file hosted on a Wikia or on other websites (ending with .css on the url and contains changes for the wikia skin elements on the file). The syntax is as follows:
@import "path_to_file_to_import.css"
Per the above example, to import Local.css into Wikia.css, place this at the top of your Wikia.css file:
@import "/load.php?mode=articles&only=styles&articles=MediaWiki:Local.css";
You can read more on this method here.
See also
Further help and feedback
- Browse and search other help pages at Help:Contents
- Check Fandom Community Central for sources of further help and support
- Check Contacting Fandom for how to report any errors or unclear steps in this article