[ 6 posts ]

Morgan Cheng

YUI Contributor

  • Username: MorganCheng
  • Joined: Mon Nov 15, 2010 2:14 am
  • Posts: 4
  • Location: Beijing, China
  • Twitter: morgancheng
  • GitHub: mocheng
  • Gists: mocheng
  • Offline
  • Profile

How to self-host YUI3?

Post Posted: Mon Nov 15, 2010 2:24 am
+0-
Is it possible to self-host YUI3?

I want all javascript files to be downloaded from my own servers(or given CDN). I tried to put yui-min.js in my server; and have one HTML file referring to that yui-min.js file

Code:
<script type="text/javascript" src="yui-min.js"></script>


However, Firebug shows that other YUI3 javascript resources are still loaded from Yahoo API

http://yui.yahooapis.com/3.2.0/build/lo ... der-min.js

http://yui.yahooapis.com/combo?3.2.0/bu ... ate-min.js

Did I miss something that should be customized to make YUI3 files loaded from my own server?

Thanks

Matt Parker

YUI Contributor

  • Username: mattatlamplight
  • Joined: Mon Apr 20, 2009 12:03 pm
  • Posts: 465
  • Location: London UK
  • GitHub: mattparker
  • Gists: mattparker
  • Offline
  • Profile

Re: How to self-host YUI3?

Post Posted: Mon Nov 15, 2010 6:13 am
+0-
Hi,

Yes

If you want to serve them in the same way as Yahoo servers (ie using loader), you'll need a server that can do so: start here for info on the php loader http://yuilibrary.com/projects/phploader

Alternatively you can use the dependency configurator http://developer.yahoo.com/yui/3/configurator/ to work out what js you need, save the file to your server, and include it as a normal js script, but of course then you don't have any of the dynamic content loading.

Matt

Jeff Craig

YUI Contributor

  • Username: foxxtrot
  • Joined: Thu Dec 04, 2008 9:20 am
  • Posts: 135
  • Location: Pullman, WA
  • Twitter: foxxtrot
  • GitHub: foxxtrot
  • Gists: foxxtrot
  • IRC: foxxtrot
  • YUI Developer
  • Offline
  • Profile

Re: How to self-host YUI3?

Post Posted: Mon Nov 15, 2010 6:54 am
+0-
Loader should just work from your server, though as Matt says you'll want to use something like phploader to handle combo loading.

Give it an absolute path, and keep the files in the same directory structure as in the release tarball, so that you have a path like '/js/3.3.0pr1/yui/yui-min.js' in your script tags.

Daniel Stockman

YUI Contributor

  • Username: evocateur
  • Joined: Sat Nov 14, 2009 12:07 pm
  • Posts: 1
  • Location: Seattle, WA
  • Twitter: evocateur
  • GitHub: evocateur
  • Gists: evocateur
  • Offline
  • Profile

Re: How to self-host YUI3?

Post Posted: Mon Nov 15, 2010 10:57 am
+1-
To load files locally, you'll need to set the "base" config property, via a global YUI_config object or the config object passed to the sandbox invocation (I highly recommend the YUI_config pattern). When you get the combo loader set up locally, you can set the "comboBase" property.

Code:
YUI_config = {
    base: "path/to/your/local/YUI3",
    comboBase: "path/to/local/combo"
};

Here is the API reference that lists all the available config properties:
http://developer.yahoo.com/yui/3/api/Loader.html

Morgan Cheng

YUI Contributor

  • Username: MorganCheng
  • Joined: Mon Nov 15, 2010 2:14 am
  • Posts: 4
  • Location: Beijing, China
  • Twitter: morgancheng
  • GitHub: mocheng
  • Gists: mocheng
  • Offline
  • Profile
Tags:

Re: How to self-host YUI3?

Post Posted: Mon Nov 15, 2010 6:13 pm
+0-
Thank you all for the replies.

I'm wondering how Yahoo API CDN implements the combo. If every combo request goes to PHP loader, would it bring heavy burden to CDN and bad performance?

I suppose there is server side cache.

Caridy Patino

YUI Contributor

  • Username: caridy
  • Joined: Mon Dec 08, 2008 5:40 pm
  • Posts: 491
  • Location: Miami, FL
  • Twitter: caridy
  • GitHub: caridy
  • Gists: caridy
  • IRC: caridy
  • YUI Developer
  • Offline
  • Profile

Re: How to self-host YUI3?

Post Posted: Mon Nov 15, 2010 7:40 pm
+0-
Hey Morgan,

PHP Loader is similar to the one running on Y! CDN. It uses APC cache per request basics, so only the first request will be computed. On top of that, there are not too much to do, it's just a dump concat process, caching the result using the url as the key :)

More info about it here:
http://github.com/yui/phploader/

Best Regards,
Caridy
  [ 6 posts ]
Display posts from previous:  Sort by  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum