March 16, 2010

Secure YUI Combo Usage Guide

This post explains how to transit from unsecure (HTTP) based YUI combo service to Secured(HTTPS) based Combo Service. Making this transit to this secure YUI Combo service is pretty simple. This process requires you to just do 2-3 string replacements in your existing yui application, these replacements are:

  1. Load YUI minimal JavaScript? file via this secure service.
    <-- Change following script include -->
    <script src="http://yui.yahooapis.com/3.0.0/build/yui/yui-min.js"></script> 
    <-- replace it with this one -->
    <script src="https://yuicombo.appspot.com/combo?3.0.0/build/yui/yui-min.js"></script> 
  2. Change the configuration options for YUI Loader, to specify “comboBase” attribute pointing to this service.
    <script type="text/javascript"> 
    YUI({combine: true, timeout: 10000, comboBase : 'https://yuicombo.appspot.com/combo?'}).use("overlay", function(Y) {
    // ... your same post YUI modules load code
    // ... will go here
    }
    </script> 
  3. Load any additional YUI CSS via this service.
    <link type="text/css" rel="stylesheet" href="https://yuicombo.appspot.com/combo?3.0.0/build/cssfonts/fonts-min.css" /> 

Live Code Samples

Some of YUI-3 live samples are copied and updated to use this secure service. Here are the links to these samples

USAGE NOTE !

The secure YUI Combo Service URL (https://yuicombo.appspot.com/combo?) is hosted over Google App Engine. It uses the free quota of app engine, so this is not production ready for you, its just for demo !

So feel free to test if it works for you using this service, Google app engine has decent limits on free quota. So I am sure I can at least demo it from there :-)

Production Usage: All the code for this service is available on this googlecode project. To use it in production environment, check out the code for this Java web-app and feel free to host it on your own app engine instance or existing java servers. The code is purely Core Java Implementation + Servlets. 

In case of queries regarding hosting or deploying this code to your App Engine or Java Server instance please let me know.