Wikimedia Scripts/Policy draft
This is a Policy Draft for the proposed project Wikimedia Scripts.
Best practices
editAll the advice presented here is not mandatory, but it's highly recommended to follow it.
Libraries
editUse jQuery and the other available JavaScript libraries when suitable. Use OOjs UI (see documentation) as a standard User experience.
- HTML5
<progress>
is allowed- alternative: jQueryUI progressbar
- HTML5
<
input
type="range">
is allowed- alternative: jQueryUI slider
- HTML5
<datalist>
is allowed- alternatives:
- JavaScript
alert
,prompt
, andconfirm
are allowed,- also: consider using
mw.notify
for less intrusive messages
- also: consider using
- cookies for data that doesn't have to be sent to the server should be avoided
- but OO.ui.Dialog is recommended instead
- Tip: AlertStyler will provide
jQuery.alert
,jQuery.prompt
andjQuery.confirm
- alternatives:
- jQueryUI dialog
- jQuery.jStorage (preferred for compatibility reasons)
- HTML5 WebStorage (
LocalStorage
/SessionStorage
)
- if it's necessary to use cookies, use jQuery.cookie
AJAX
editUse Ajax when possible: it's easier to do a POST request (with jQuery) than storing somewhere the action to make and then manipulate the edit page. It's very inadvisable to do it, unless some strong interaction or control by the user is needed.
Usually, all actions can be made directly from the page: for example, a script to help voting Quality Images on Commons, ...
Intelligent Guess
editUse 'Artificial Intelligence' to guess as many things as possible without the user's interaction: for example, a voting script would check automatically if every user has the requirements, and in case of negative result, provide the user a simple way to 'rollback' the vote.
Presentation
editGive your code the best indentation possible, according to the policies. It's not useful to compress and 'minify' the source code by any means, since this is made by ResourceLoader in production.