<?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; lazy load script</title>
	<atom:link href="http://blog.justswell.org/tag/lazy-load-script/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>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>

