March 17, 2010

Secure yui combo service (Over HTTPS)

YUI Dependency Configurator is a great tool for getting a single unified JS or CSS instead of several css/js files. Only problem with that is it doesn't works over "HTTPS". Browser's like Internet Explorer fail to load a web page delivered over HTTPS containing JS/CSS delivered over un-secure(HTTP) URLs.

The good news is that YUI team left a great possibility to change the combo base for service. “Combo base”  is basically YUI combo service base dir. Ex: “http://yui.yahooapis.com/combo?”.

New Secure YUI Combo Service

So I decided to use this possibility and I created a  Secure YUI Combo Service. This service is a secure wrapper over the existing YUI combo service i.e. for every combo service request it delegates the call to original YUI combo service and returns the response back.

Following are some highlights of this service:

  1. It uses the high speed internet provided by Google, its hosted over “Google App Engine”.
  2. Its Open source on “New BSD License” and is hosted Google Code, here.
  3. Its support 3 HTTP METHODS i.e. GET OPTIONS HEAD. It also returns the same response headers as of Original YUI Combo Service. So browsers might make use of intelligent caching.
  4. The same service works with both YUI 2 & 3.

Service Environment

  • Service Combo Endpoint :  https://yuicombo.appspot.com/combo?
  • Service Implementation : Its a J2EE Servlet.
  • Service Hosting : Hosted @ Google App Engine.
  • Service Dependencies: Apart from being a Servlet, its pure Core Java Code. So no dependencies on any jar or library, not even Apache Http Client.

Developers - Getting Started Guide

All the details regarding setup and testing this service over HTTPS are available in this here.

Note for force.com developers

Force.com developers creating visualforce pages using YUI v2/3 face the same problem in Internet explorer i.e. force.com servers deliver content over HTTPS and YUI combo service is not available yet on HTTPS. Rest all browsers are pretty nice with unsecure YUI Combo Service. So this service can be useful for all visualforce developers using YUI. Internet Explorer is a huge pain but we can’t avoid it :-)

References