Moodle

Allow YUI files to be loaded from Yahoo directly

Details

  • Type: New Feature New Feature
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 1.9
  • Fix Version/s: 2.0
  • Component/s: AJAX
  • Labels:
    None
  • Database:
    Any
  • Affected Branches:
    MOODLE_19_STABLE
  • Fixed Branches:
    MOODLE_20_STABLE

Description

I am always looking at ways to speed up our page loads. One easy way to get a bit more speed is to load the YUI library directly from Yahoo's servers. They do allow this and have a page dedicated to doing it here: http://developer.yahoo.com/yui/articles/hosting/

I am attaching a patch that is a simple modification to the ajaxlib.php file. It also relies on a CFG parameter to be set. The default is to load the files from the local filesystem. Only if the CFG variable is set will it load them from Yahoo.

One thing that I would like to change with this is that I had to hardcode the YUI version number. It would be great if that was an easier bit of information to pull dynamically. I thought about parsing the YUI README file to get the version, but felt like that was a bit sloppy.

Activity

Hide
Nicolas Connault added a comment -

Improved Bryce's patch and applied. YUI version number is kept in a simple version.php file, to be updated manually when updating the YUI libraries.

Show
Nicolas Connault added a comment - Improved Bryce's patch and applied. YUI version number is kept in a simple version.php file, to be updated manually when updating the YUI libraries.
Hide
Eloy Lafuente (stronk7) added a comment -

Hi Nico,

aren't there limits (restrictions) about js only being able to connect to server it comes from, or something similar. Or perhaps I'm wrong and that's only java applets.

Anyway, sounds ok for me to provide that ability via CFG parameter. +1 for it.

Ciao

Show
Eloy Lafuente (stronk7) added a comment - Hi Nico, aren't there limits (restrictions) about js only being able to connect to server it comes from, or something similar. Or perhaps I'm wrong and that's only java applets. Anyway, sounds ok for me to provide that ability via CFG parameter. +1 for it. Ciao
Hide
Bryce Thornton added a comment -

Eloy,

You're thinking of the "same origin" policy for Javascript:

http://www.mozilla.org/projects/security/components/same-origin.html

This refers to calling other servers while executing Javascript. All we're doing here is loading the YUI libraries from Yahoo's server. They will function just like we loaded them from our own server.

Thanks,
Bryce

Show
Bryce Thornton added a comment - Eloy, You're thinking of the "same origin" policy for Javascript: http://www.mozilla.org/projects/security/components/same-origin.html This refers to calling other servers while executing Javascript. All we're doing here is loading the YUI libraries from Yahoo's server. They will function just like we loaded them from our own server. Thanks, Bryce
Hide
Petr Škoda (skodak) added a comment -

this can not be enabled by default, I have changed the default in cvs

Show
Petr Škoda (skodak) added a comment - this can not be enabled by default, I have changed the default in cvs
Hide
Petr Škoda (skodak) added a comment -

reopening, please add a warning that all users must have internet access

Show
Petr Škoda (skodak) added a comment - reopening, please add a warning that all users must have internet access
Hide
Nicolas Connault added a comment -

Added warning.

Show
Nicolas Connault added a comment - Added warning.
Hide
Nicolas Connault added a comment - - edited

See this YUI blog article for an interesting approach to loading external JS files:
http://yuiblog.com/blog/2008/07/22/non-blocking-scripts/

Show
Nicolas Connault added a comment - - edited See this YUI blog article for an interesting approach to loading external JS files: http://yuiblog.com/blog/2008/07/22/non-blocking-scripts/
Hide
Andrew Davis added a comment -

Reopening. Turning this on results in the following messages being output half a dozen times or so. Maybe version.php wasn't added to the repository.

Warning: include(/home/andrew/Desktop/repos/moodle/lib/yui/version.php) [function.include]: failed to open stream: No such file or directory in /home/andrew/Desktop/repos/moodle/lib/ajax/ajaxlib.php on line 1278

Notice: Undefined variable: yuiversion in /home/andrew/Desktop/repos/moodle/lib/ajax/ajaxlib.php on line 1279

Show
Andrew Davis added a comment - Reopening. Turning this on results in the following messages being output half a dozen times or so. Maybe version.php wasn't added to the repository. Warning: include(/home/andrew/Desktop/repos/moodle/lib/yui/version.php) [function.include]: failed to open stream: No such file or directory in /home/andrew/Desktop/repos/moodle/lib/ajax/ajaxlib.php on line 1278 Notice: Undefined variable: yuiversion in /home/andrew/Desktop/repos/moodle/lib/ajax/ajaxlib.php on line 1279
Hide
Petr Škoda (skodak) added a comment -

This does not seem to be a problem any more, closing.
Thanks

Show
Petr Škoda (skodak) added a comment - This does not seem to be a problem any more, closing. Thanks

Dates

  • Created:
    Updated:
    Resolved: