If you’ve been following this blog (or are going to read some previous posts), you’ll most likely want to try out Swell for yourself.
I posted a while ago about CDN technology allowing anyone to start using Swell while linking it on a Content Delivery Network, meaning visitors will always get the library from the closest point, and as the first milestone has been reached, I guess it’s time to do a little introduction on the way you will be able to make Swell-enabled applications.
At first, you need to determine which component you need. If you try to implement one of the examples in previous or future posts, you can get this information from the code snippet itself.
In our case, let’s say we want to use setStyle() to change our page’s background color. We want it black, the reason is irrelevant.
This will get our background black:
$(document.body).setStyle({backgroundColor : '#000'});
As setStyle() is part of the Core.Element Swell library, we’ll need it, but also its dependencies. “Core.Element” requires “Core.Hashtable” which requires “Core.CustomEvent” which requires “Core.Core”, who are all requiring the “Swell” namespace itself.
Dependencies are a pain, so we’ll just ignore them and include “Element” (Core.Element‘s alias name). The server-side system will automatically include everything we need in a very convenient way.
http://get.swl.fr/1.0/Element.js
Yep, that’s all. With this URL, I’ll include the Element lib from Swell, with all its dependencies, from the “1.0″ stable branch. If you feel adventurous, you can replace “1.0″ with “trunk” and get bleeding edge code.
<script type="text/javascript" src="http://get.swl.fr/1.0/Element.js"></script> <script type="text/javascript"> $(document.body).setStyle({backgroundColor : '#000'}); </script>
Looks simple, try it too!
Finally, you might want to include more than one library. This is also possible, and is really easy. Let’s say we want Ajax and Event too, the URL would become: http://get.swl.fr/1.0/Element/Ajax/Event.js. The (obvious) goal is to include everything you need without including tons of different files.
Just a final note: using Swell only to change your page’s background color is called overkill. Try out the other examples on the blog and start building rich web applications!
Tags: CDN, Swell, Swell Installation










