<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>SwellJS - another big fish in the sea &#187; lazyloading</title>
	<atom:link href="http://blog.justswell.org/tag/lazyloading/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.justswell.org</link>
	<description>well-minded javascript library</description>
	<lastBuildDate>Fri, 20 Aug 2010 20:48:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
		<item>
		<title>Dazzling performance with JSONP and Swell</title>
		<link>http://blog.justswell.org/dazzling-performance-with-jsonp-and-swell/</link>
		<comments>http://blog.justswell.org/dazzling-performance-with-jsonp-and-swell/#comments</comments>
		<pubDate>Mon, 27 Apr 2009 15:42:23 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Swell]]></category>
		<category><![CDATA[json webservices]]></category>
		<category><![CDATA[jsonp]]></category>
		<category><![CDATA[lazyloading]]></category>

		<guid isPermaLink="false">http://blog.justswell.org/?p=154</guid>
		<description><![CDATA[For an upcoming work we figured it would be useful to add JSONP support in our Asset component in order to load the given URL and once loaded, passback the JSON to a handler with the content. What&#8217;s interesting with this approach is that we don&#8217;t rely on any hack to get the response such [...]]]></description>
			<content:encoded><![CDATA[<p>For an upcoming work we figured it would be useful to add JSONP support in our Asset component in order to load the given URL and once loaded, passback the JSON to a handler with the content.</p>
<p>What&#8217;s interesting with this approach is that we don&#8217;t rely on any hack to get the response such as evaluating all the script files in head or loading the content asynchronously then appending it.</p>
<p>There are numerous advantages using our solution :</p>
<ul>
<li>You can load the JSON from multiple sources but keep a single handler, each JSONP file processed will be passed back as an argument</li>
<li>You can have a single handler for the whole sequence or listen events of each JSONP file being loaded with CustomEvents</li>
<li>The tags are removed from the DOM once loaded, this avoid memleaks or JSONP collision</li>
<li>This approach is robust and works equally between browsers even on old ones like MSIE 5.5</li>
</ul>
<p>here&#8217;s a little example of what can be done:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">Swell.<span style="color: #660066;">Core</span>.<span style="color: #660066;">Asset</span>.<span style="color: #660066;">load</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'jsonp'</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#91;</span>
    <span style="color: #3366CC;">'http://search.yahooapis.com/ImageSearchService/V1/imageSearch?appid=YahooDemo&amp;query=rideback&amp;output=json&amp;callback='</span><span style="color: #339933;">,</span>
    <span style="color: #3366CC;">'http://search.yahooapis.com/ImageSearchService/V1/imageSearch?appid=YahooDemo&amp;query=saintseiya&amp;output=json&amp;callback='</span>
<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> _n <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> _n <span style="color: #339933;">&lt;</span> arguments.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> _n<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003366; font-weight: bold;">var</span> yim <span style="color: #339933;">=</span> arguments<span style="color: #009900;">&#91;</span>_n<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> _i <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> _im<span style="color: #339933;">;</span> _im <span style="color: #339933;">=</span> yim.<span style="color: #660066;">ResultSet</span>.<span style="color: #660066;">Result</span><span style="color: #009900;">&#91;</span>_i<span style="color: #339933;">++</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            html.<span style="color: #660066;">img</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
                <span style="color: #3366CC;">'src'</span>   <span style="color: #339933;">:</span> _im.<span style="color: #660066;">Thumbnail</span>.<span style="color: #660066;">Url</span><span style="color: #339933;">,</span>
                <span style="color: #3366CC;">'alt'</span>   <span style="color: #339933;">:</span> _im.<span style="color: #660066;">Title</span><span style="color: #339933;">,</span>
                <span style="color: #3366CC;">'title'</span> <span style="color: #339933;">:</span> _im.<span style="color: #660066;">Title</span><span style="color: #339933;">,</span>
                <span style="color: #3366CC;">'width'</span> <span style="color: #339933;">:</span> _im.<span style="color: #660066;">Thumbnail</span>.<span style="color: #660066;">Width</span><span style="color: #339933;">,</span>
                <span style="color: #3366CC;">'height'</span><span style="color: #339933;">:</span> _im.<span style="color: #660066;">Thumbnail</span>.<span style="color: #660066;">Height</span>
            <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">appendTo</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'receiver'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.justswell.org/dazzling-performance-with-jsonp-and-swell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Introducing Swell&#8217;s lazy loader utility</title>
		<link>http://blog.justswell.org/introducing-swells-lazy-loader-utility/</link>
		<comments>http://blog.justswell.org/introducing-swells-lazy-loader-utility/#comments</comments>
		<pubDate>Fri, 10 Apr 2009 13:23:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Swell]]></category>
		<category><![CDATA[lazy load css]]></category>
		<category><![CDATA[lazy load script]]></category>
		<category><![CDATA[lazyloading]]></category>
		<category><![CDATA[ondemand css]]></category>

		<guid isPermaLink="false">http://blog.justswell.org/?p=137</guid>
		<description><![CDATA[As we are preparing the upcoming release of Swell, we are actively working on a true and efficient dependency management system, and one of the key feature of the dependency manager is the ability to grab resources once the page is loaded. Swell&#8217;s Core should be the only resource you would ever need to get [...]]]></description>
			<content:encoded><![CDATA[<p>As we are preparing the upcoming release of Swell, we are actively working on a true and efficient dependency management system, and one of the key feature of the dependency manager is the ability to grab resources once the page is loaded.</p>
<p>Swell&#8217;s Core should be the only resource you would ever need to get started,  it is not an understatement to say that we&#8217;ll lose adopters if the system is too hard to build.<br />
Every component should be able to load its own UI definition, I mean being able to lazy load any css or  image resource it needs.</p>
<p>Separation of concerns will help us to build a better library,  that&#8217;s the way it should be, that&#8217;s the way we are !</p>
<p>We have looked at the various javascript lazyloading implementations on the web, some are interesting and well-minded, some others are just bloated.</p>
<h2 style="margin:20px 0;">Keep it simple stupid!</h2>
<p>Our lazy loading implementation is able to load and monitor script, css and image resources,  for example you want to use the Element component in your page and then want to use it when available into the global scope.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">/** For a single script file without callback */</span>
Swell.<span style="color: #660066;">Core</span>.<span style="color: #660066;">Asset</span>.<span style="color: #660066;">load</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'script'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'Core/Element.js'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009966; font-style: italic;">/** For multiple script files with a callback when all resources are loaded */</span>
Swell.<span style="color: #660066;">Core</span>.<span style="color: #660066;">Asset</span>.<span style="color: #660066;">load</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'script'</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'Core/Element.js'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'Core/Hashtable.js'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'foo'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'meh'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009966; font-style: italic;">/** Custom event when a single file is loaded */</span>
Swell.<span style="color: #660066;">Core</span>.<span style="color: #660066;">Asset</span>.<span style="color: #660066;">onResourceLoaded</span>.<span style="color: #660066;">subscribe</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>type<span style="color: #339933;">,</span> res<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>type <span style="color: #339933;">===</span> <span style="color: #3366CC;">'img'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #006600; font-style: italic;">// Do something</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009966; font-style: italic;">/** Advanced example */</span>
<span style="color: #003366; font-weight: bold;">var</span> _imgs <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span>document.<span style="color: #660066;">body</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">getByClassName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'swell-image-asset'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'img'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">setAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #3366CC;">'src'</span> <span style="color: #339933;">:</span> <span style="color: #3366CC;">'blank.png'</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
    .<span style="color: #660066;">addEvent</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'mouseover'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
        <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'loading'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        Swell.<span style="color: #660066;">Core</span>.<span style="color: #660066;">Asset</span>.<span style="color: #660066;">load</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'img'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'largeimage.jpg'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>collection<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> _i <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> _i <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> collection.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> _i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">setAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #3366CC;">'src'</span> <span style="color: #339933;">:</span> collection<span style="color: #009900;">&#91;</span>_i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">src</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                collection<span style="color: #009900;">&#91;</span>_i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Have fun !</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.justswell.org/introducing-swells-lazy-loader-utility/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

