שיחת מדיה ויקי:Common.js: הבדלים בין גרסאות בדף

תגובה אחרונה: לפני 13 שנים מאת Krinkle בנושא Double jQuery
תוכן שנמחק תוכן שנוסף
Krinkle (שיחה | תרומות)
Double jQuery
(אין הבדלים)

גרסה מ־20:42, 11 בפברואר 2011

Double jQuery

Hi, As of October 2010 jQuery has been loaded by default on all pages within the Wikimedia domain. Back then the $ alias was not set so you had to use jQuery. I noticed that this wiki is loading an additional instance of jQuery:


document.write('<script type="text/javascript" src="' 
             + 'http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>');

This is a problem because it overrides the jQuery loaded by MediaWiki:

/* MediaWiki */
jQuery = .......
jQuery.plugin = .....

/* he.wikisource.org */
http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js

jQuery.plugin is now gone.

If you wish to use the $-variable as a shortcut to jQuery, use the following:

window.$ = jQuery;

// Now you can use $
$('#something').hide();

As of today, since 1.17 is deployed, the $-variable is automatically a shortcut to jQuery so you dont have to do that either. For that reason please remove the following two lines:


document.write('<script type="text/javascript" src="' 
             + 'http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>');
  • No longer overrides the one loaded by MediaWiki (which is a different version (1.4.2))
  • $ is already set as alias to jQuery
  • Loads the page faster (loading once instead of twice saves time)!

Thanks in advance, Krinkle 20:42, 11 בפברואר 2011 (IST)תגובה

PS: If you have any questions, feel free to ask me or someone else in #wikimedia-dev on irc.freenode.org or leave a message on my Talk page on Meta-Wiki. Krinkle 20:42, 11 בפברואר 2011 (IST)תגובה
חזרה לדף "Common.js".