https://bugzilla.wikimedia.org/show_bug.cgi?id=27488

--- Comment #26 from Nux <[email protected]> 2011-04-09 19:39:41 UTC ---
(In reply to comment #25)
> I have laid the ground work for this in r85616.
> 
> The startup, jquery and mediawiki modules are now loaded in the <head>, along
> with any modules flagged with 'position' => 'top'. Modules whose position is
> set to 'bottom' (this is the default) are still loaded at the bottom of the
> <body>, which is also where legacy JS (from non-RL-ified extensions), user
> preferences, site JS and user JS is loaded.

Site JS and user JS should be at top. Users and site administrators load
libraries in their script and they must be read at least on doc.ready and (as
shown in attached test results) this will NOT be guaranteed when they are in
the footer.

Also legacy JS is in fact a library that must also be ready before the page is
loaded.

I think you should add Mediawiki:[email protected] (or similar) so that scripts
that can be moved would be moved by site administrators.

IMHO the only scripts that could stay in the footer are gadgets. They are the
only scripts that have dependencies in place. Still, some of them change
interface and so it should still be possible to put them (and all their
dependencies) in the header. Maybe this could be differentiated with name:
* [email protected] => preference to load in a footer (might be loaded
in head)
* [email protected] => preference to load in a header (must not be
loaded in footer)
* Script-name-not-containing-above.js => developers don't know or don't care.

Furthermore to really make things better script developers should divide their
scripts and use the following syntax:

  function MyVeryBasicInit ()
  {
    // Some basic functionality like adding buttons that are to be activated
later
  }
  $(function(){
    MyVeryBasicInit();
    importScript('User:Me/This is a part where I don't change interface and is
not a library, I will activate my buttons only when this is loaded.js')
  );

And the names should that long ;-).

> I guess all we need to do now is identify modules that should load in the
> <head> rather than in the <body>, and flag them with 'position' => 'top'. This
> should only be done for modules that would otherwise cause a flash of unstyled
> content or have another good reason to live in the <head>: loading things in
> the <head> degrades performance, as previously mentioned.

This is not true - it doesn't degrade performance. It makes the page start
appearing slower which is not the same. Users will mostly want to have scripts
loaded before they work on a page (as shown before). So this might be true in
some cases, but is not a general truth and I find it as a dangerous myth.

-- 
Configure bugmail: https://bugzilla.wikimedia.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

_______________________________________________
Wikibugs-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l

Reply via email to