<?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>info.michael-simons.eu &#187; JavaScript</title>
	<atom:link href="http://info.michael-simons.eu/tag/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://info.michael-simons.eu</link>
	<description>Just another nerd blog</description>
	<lastBuildDate>Wed, 25 Jan 2012 07:53:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Optimizing web resources with wro4j, Spring and ehcache</title>
		<link>http://info.michael-simons.eu/2012/01/18/optimizing-web-resources-with-wro4j-spring-and-ehcache/</link>
		<comments>http://info.michael-simons.eu/2012/01/18/optimizing-web-resources-with-wro4j-spring-and-ehcache/#comments</comments>
		<pubDate>Wed, 18 Jan 2012 10:18:11 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[English posts]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Minimization]]></category>
		<category><![CDATA[Spring]]></category>
		<category><![CDATA[wro4j]]></category>

		<guid isPermaLink="false">http://info.michael-simons.eu/?p=647</guid>
		<description><![CDATA[I think that almost no website today can do without JavaScript. There are some incredible good JavaScript libraries like jQuery for which an enormous mass of plugins and extensions exits. The downside of this is, that for example the JavaScript code of my daily picture project Daily Fratze is bigger than the whole startpage of [...]]]></description>
			<content:encoded><![CDATA[<p>I think that almost no website today can do without JavaScript. There are some incredible good JavaScript libraries like jQuery for which an enormous mass of plugins and extensions exits.</p>
<p>The downside of this is, that for example the JavaScript code of my daily picture project <a href="http://dailyfratze.de">Daily Fratze</a> is bigger than the whole startpage of my first &#8220;homepage&#8221; was.</p>
<p>With every problem there is a solution, namely JavaScript compressors and minifier. Those tools can compress the code by removing superfluous whitespaces, renaming variables and functions or even by optimizing the code.</p>
<p>So far i have used the <a href="http://alchim.sourceforge.net/yuicompressor-maven-plugin/compress-mojo.html">YUI compressor maven mojo</a> in my Spring based projects. This is a build time solution that compresses JavaScript and CSS files when creating a war file.</p>
<p>For me it had several disadvantages: I don&#8217;t see the effect of compressing when i develop my application and it could not concatenate multiple script files.</p>
<p>The later is important because every additional request a browser makes slows down the loading of a webpage. And manual hacking all JavaScript into one file? No way…</p>
<p><a href="http://code.google.com/p/wro4j/">wro4j</a> to the rescue:</p>
<blockquote>
<p>Free and Open Source Java project which brings together almost all the modern web tools: JsHint, CssLint, JsMin, Google Closure compressor, YUI Compressor, UglifyJs, Dojo Shrinksafe, Css Variables Support, JSON Compression, Less, Sass, CoffeeScript and much more. In the same time, the aim is to keep it as simple as possible and as extensible as possible in order to be easily adapted to application specific needs.</p>
</blockquote>
<p>My goal was to integrate wro4j with Spring and ehcache with a minimum number of additional configuration files.</p>
<p>If you&#8217;re interested in some of my ideas, read on:</p>
<p><span id="more-647"></span></p>
<p><em>Please note: This is not the complete solution. The wro.xml is missing as well as some of my infrastructure ideas. But you should get the idea on how to use wro4j with Spring, extend it with your own caching strategy and configure the processors.</em></p>
<p>First step: Creating a WroFilter implementation that doesn&#8217;t depend on wro.properties:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Map</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Properties</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">ro.isdc.wro.http.ConfigurableWroFilter</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">ro.isdc.wro.manager.factory.WroManagerFactory</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Wro4jFilter <span style="color: #000000; font-weight: bold;">extends</span> ConfigurableWroFilter <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">final</span> WroManagerFactory factory<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> Wro4jFilter<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">final</span> Map<span style="color: #339933;">&lt;</span>String, String<span style="color: #339933;">&gt;</span> properties, <span style="color: #000000; font-weight: bold;">final</span> WroManagerFactory wroManagerFactory, <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">boolean</span> debug<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">factory</span> <span style="color: #339933;">=</span> wroManagerFactory<span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">Properties</span> p <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Properties</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		p.<span style="color: #006633;">putAll</span><span style="color: #009900;">&#40;</span>properties<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		p.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;debug&quot;</span>, <span style="color: #003399;">Boolean</span>.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span>debug<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>				
		<span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">setProperties</span><span style="color: #009900;">&#40;</span>p<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>		
	<span style="color: #009900;">&#125;</span>
&nbsp;
	@Override
	<span style="color: #000000; font-weight: bold;">protected</span> WroManagerFactory newWroManagerFactory<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>		
		<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">factory</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>	
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>As you see this filter accepts a map that is converted to a properties instance from which the superclass is configured. I also inject the WroManagerFactory which will be my interface to ehcache. Finally i can overwrite the debug flag.</p>
<p>This bean is instantiated through an @Configuration class like so:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">@Configuration
@Profile<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;prod&quot;</span><span style="color: #009900;">&#41;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> WebConfigProd <span style="color: #000000; font-weight: bold;">extends</span> WebConfig <span style="color: #009900;">&#123;</span>
	@Bean<span style="color: #009900;">&#40;</span>name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;wroFilter&quot;</span><span style="color: #009900;">&#41;</span>
	@Override
	<span style="color: #000000; font-weight: bold;">public</span> Filter getWroFilter<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">new</span> Wro4jFilter<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">defaultWroProperties</span>, <span style="color: #000000; font-weight: bold;">new</span> Wro4jManagerFactory<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">cacheManager</span><span style="color: #009900;">&#41;</span>, <span style="color: #000066; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>The defaultWroProperties is a <code>Map<String,String></Code> created from the Spring Environment so that i can keep my wro4j options in my application properties file. cacheManager is an instance of <code>net.sf.ehcache.CacheManager</code>. The CacheManager is needed for my own WroManagerFactory which you'll see later.</p>
<p>To use this filter you need the Spring DelegatinFilterProxy:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;filter<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;filter-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>webResourceOptimizer<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/filter-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;filter-class<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.springframework.web.filter.DelegatingFilterProxy<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/filter-class<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;init-param<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>targetBeanName<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/param-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param-value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>wroFilter<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/param-value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/init-param<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>    	
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;init-param<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>targetFilterLifecycle<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/param-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param-value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>true<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/param-value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>    	
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/init-param<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/filter<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Having set the targetFilterLifecycle to true is actually essential because the original <code>ro.isdc.wro.http.WroFilter</code> relies on the init method.</p>
<p>So far i only have the filter. What's missing is the wro4j model. This is where groups of JavaScript and CSS files are defined and it can be - among others - an xml file. I want mine to reside with my other configuration files in an dedicated package. To accomplish that i've created a special WroManagerFactory:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.InputStream</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">net.sf.ehcache.CacheManager</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">ro.isdc.wro.cache.CacheEntry</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">ro.isdc.wro.cache.CacheStrategy</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">ro.isdc.wro.cache.ContentHashEntry</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">ro.isdc.wro.extensions.processor.css.YUICssCompressorProcessor</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">ro.isdc.wro.extensions.processor.js.GoogleClosureCompressorProcessor</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">ro.isdc.wro.manager.factory.BaseWroManagerFactory</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">ro.isdc.wro.model.factory.WroModelFactory</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">ro.isdc.wro.model.factory.XmlModelFactory</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">ro.isdc.wro.model.resource.processor.factory.ProcessorsFactory</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">ro.isdc.wro.model.resource.processor.factory.SimpleProcessorsFactory</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">ro.isdc.wro.model.resource.processor.impl.css.CssUrlRewritingProcessor</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.google.javascript.jscomp.CompilationLevel</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Wro4jManagerFactory <span style="color: #000000; font-weight: bold;">extends</span> BaseWroManagerFactory <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #003399;">String</span> CACHE_NAME <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;some_cache_name&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">final</span> CacheManager cacheManager<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> Wro4jManagerFactory<span style="color: #009900;">&#40;</span>CacheManager cacheManager<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">cacheManager</span> <span style="color: #339933;">=</span> cacheManager<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	@Override
	<span style="color: #000000; font-weight: bold;">protected</span> ProcessorsFactory newProcessorsFactory<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">final</span> SimpleProcessorsFactory rv <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> SimpleProcessorsFactory<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #666666; font-style: italic;">// URLs in CSS needs to be rewritten as it is served from a different location than the original files. I'm not using @import statements, otherwise the appropriate processor should be added for rewriting them as well</span>
		rv.<span style="color: #006633;">addPreProcessor</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> CssUrlRewritingProcessor<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	
                <span style="color: #666666; font-style: italic;">// JavaScript compression by the Google Closure compressor	</span>
		rv.<span style="color: #006633;">addPreProcessor</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> GoogleClosureCompressorProcessor<span style="color: #009900;">&#40;</span>CompilationLevel.<span style="color: #006633;">SIMPLE_OPTIMIZATIONS</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #666666; font-style: italic;">// And css by YUI Css Compressor</span>
		rv.<span style="color: #006633;">addPreProcessor</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> YUICssCompressorProcessor<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">return</span> rv<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>			
&nbsp;
	@Override
	<span style="color: #000000; font-weight: bold;">protected</span> WroModelFactory newModelFactory<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">new</span> XmlModelFactory<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			@Override
			<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #003399;">InputStream</span> getModelResourceAsStream<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">getClass</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getResourceAsStream</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/foo/bar/config/wro.xml&quot;</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: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>	
&nbsp;
	@Override
	<span style="color: #000000; font-weight: bold;">protected</span> CacheStrategy<span style="color: #339933;">&lt;</span>CacheEntry, ContentHashEntry<span style="color: #339933;">&gt;</span> newCacheStrategy<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">new</span> Wro4jCacheStrategy<span style="color: #339933;">&lt;</span>CacheEntry, ContentHashEntry<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">cacheManager</span>.<span style="color: #006633;">getCache</span><span style="color: #009900;">&#40;</span>CACHE_NAME<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>	
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>The location of my wro model is handled in <code>newModelFactory</code>. Nothing special. What's more interesting is <code>newCacheStrategy</code>. It get's an ehcache <code>net.sf.ehcache.Cache</code> from the CacheManager and passes it to my caching strategy:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">net.sf.ehcache.Cache</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">net.sf.ehcache.Element</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">ro.isdc.wro.cache.CacheStrategy</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Wro4jCacheStrategy<span style="color: #339933;">&lt;</span>K, V<span style="color: #339933;">&gt;</span> <span style="color: #000000; font-weight: bold;">implements</span> CacheStrategy<span style="color: #339933;">&lt;</span>K, V<span style="color: #339933;">&gt;</span> <span style="color: #009900;">&#123;</span>	
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">final</span> Cache cache<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> Wro4jCacheStrategy<span style="color: #009900;">&#40;</span>Cache cache<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">cache</span> <span style="color: #339933;">=</span> cache<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	@Override
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">synchronized</span> <span style="color: #000066; font-weight: bold;">void</span> put<span style="color: #009900;">&#40;</span>K key, V value<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">cache</span>.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Element</span><span style="color: #009900;">&#40;</span>key, value, <span style="color: #000066; font-weight: bold;">null</span>, <span style="color: #000066; font-weight: bold;">null</span>, <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	@SuppressWarnings<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;unchecked&quot;</span><span style="color: #009900;">&#41;</span>
	@Override
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">synchronized</span> V get<span style="color: #009900;">&#40;</span>K key<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">Element</span> element <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">cache</span>.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>key<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>		
		<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #009900;">&#40;</span>V<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span>element <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span> <span style="color: #339933;">?</span> <span style="color: #000066; font-weight: bold;">null</span> <span style="color: #339933;">:</span> element.<span style="color: #006633;">getValue</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	@Override
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">synchronized</span> <span style="color: #000066; font-weight: bold;">void</span> clear<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">cache</span>.<span style="color: #006633;">removeAll</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	@Override
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">synchronized</span> <span style="color: #000066; font-weight: bold;">void</span> destroy<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">clear</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>So far i have:</p>
<ul>
<li>No need for wro.properties</li>
<li>The wro.xml model along with my other configuration files</li>
<li>The WroFilter initialized by Spring</li>
<li>Having ehcache cache my compressed and concatenated resources</li>
</ul>
<p>As you might have guessed there is also a WebConfigDev. The development configurations sets wro4j to development mode which means i can turn of minimisation at runtime through an url parameter like so "?minimize=false". </p>
<p>I didn't want to change my jsps all the time so i defined a bean that holds a property <code>minimizeResources</code> that is changable via JMX. I include my JavaScript like so:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;jsp:element</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;script&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;jsp:attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;src&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;c:url</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;/wro/project.js&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;c:param</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;minimize&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>${globalOptions.minimizeResources}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/c:param<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/c:url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/jsp:attribute<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;jsp:body</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/jsp:element<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>CSS is analog. I use the jsp:element syntax because all my jsps are actually jspx files.</p>
<p>With this solution i can easily turn off minimization in development mode. </p>
<p>In production mode i now have one compressed JavaScript file instead of 15 files and one CSS file instead of four. The first request takes a second or so but the compressed (and gzipped) content is cached. The Google Closure is actually pretty awesome and reduces my accumulated JavaScript code by over 50%. </p>
<p>Reducing the number of requests necessary had - for me - the biggest impact on my smartphone.</p>
<p>I really can recommend wro4j. It's very extensible and actually pretty easy to use. I cannot only be used to compress files but also can allow you to use CoffeeScript or SASS in Spring or JEE application.</p>
<p class="akst_link"><a href="http://info.michael-simons.eu/?p=647&amp;akst_action=share-this"  title="E-mail this, post to del.icio.us, etc." id="akst_link_647" class="akst_share_link " rel="nofollow">Share This</a>
</p>]]></content:encoded>
			<wfw:commentRss>http://info.michael-simons.eu/2012/01/18/optimizing-web-resources-with-wro4j-spring-and-ehcache/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Server push, jquery atmosphere and the throbber of doom</title>
		<link>http://info.michael-simons.eu/2011/02/03/server-push-jquery-atmosphere-and-the-throbber-of-doom/</link>
		<comments>http://info.michael-simons.eu/2011/02/03/server-push-jquery-atmosphere-and-the-throbber-of-doom/#comments</comments>
		<pubDate>Thu, 03 Feb 2011 09:42:30 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[English posts]]></category>
		<category><![CDATA[Atmosphere]]></category>
		<category><![CDATA[Comet]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://info.michael-simons.eu/?p=488</guid>
		<description><![CDATA[I&#8217;m using the Atmosphere framework to implement server push (a.k.a. Comet) in a Spring 3 application. Atmosphere includes a fine jQuery plugin to handle the client side code. The plugin works quite well and Jean-Francois, the author, has a good tutorial in his blog: Using Atmosphere’s JQuery Plug In to build applications supporting both Websocket [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m using the <a href="http://atmosphere.java.net/">Atmosphere framework</a> to implement server push (a.k.a. Comet) in a Spring 3 application.</p>
<p>Atmosphere includes a fine jQuery plugin to handle the client side code. The plugin works quite well and Jean-Francois, the author, has a good tutorial in his blog: <a href="http://jfarcand.wordpress.com/2010/06/15/using-atmospheres-jquery-plug-in-to-build-applicationsupporting-both-websocket-and-comet/">Using Atmosphere’s JQuery Plug In to build applications supporting both Websocket and Comet</a>.</p>
<p>The code works but causes webkit browsers (Chrome and Safari) to show the throbber (that little spinning thingy in tab or address bar). In iOS browsers that loading progress bar will not disappear.</p>
<p>I found some suggestions to get rid of the &#8220;throbber of doom&#8221; but none of them worked for me. </p>
<p>So here is my solution which is tested with jQuery 1.4.2 and jQuery.atmosphere 0.6.3:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script<span style="color: #339933;">&gt;</span>  	
	<span style="color: #006600; font-style: italic;">// See https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function/bind</span>
	<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #003366; font-weight: bold;">Function</span>.<span style="color: #660066;">prototype</span>.<span style="color: #660066;">bind</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #003366; font-weight: bold;">Function</span>.<span style="color: #660066;">prototype</span>.<span style="color: #660066;">bind</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span> obj <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #003366; font-weight: bold;">var</span> slice <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">slice</span><span style="color: #339933;">,</span>
			args <span style="color: #339933;">=</span> slice.<span style="color: #660066;">call</span><span style="color: #009900;">&#40;</span>arguments<span style="color: #339933;">,</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> 
			self <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">,</span> 
			nop <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;">&#125;</span><span style="color: #339933;">,</span> 
			bound <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;">return</span> self.<span style="color: #660066;">apply</span><span style="color: #009900;">&#40;</span> <span style="color: #000066; font-weight: bold;">this</span> <span style="color: #000066; font-weight: bold;">instanceof</span> nop <span style="color: #339933;">?</span> <span style="color: #000066; font-weight: bold;">this</span> <span style="color: #339933;">:</span> <span style="color: #009900;">&#40;</span> obj <span style="color: #339933;">||</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> args.<span style="color: #660066;">concat</span><span style="color: #009900;">&#40;</span> slice.<span style="color: #660066;">call</span><span style="color: #009900;">&#40;</span>arguments<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>    
			<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
			nop.<span style="color: #660066;">prototype</span> <span style="color: #339933;">=</span> self.<span style="color: #660066;">prototype</span><span style="color: #339933;">;</span>
			bound.<span style="color: #660066;">prototype</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> nop<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000066; font-weight: bold;">return</span> bound<span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #003366; font-weight: bold;">var</span> subscribe <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: #660066;">atmosphere</span>.<span style="color: #660066;">subscribe</span><span style="color: #009900;">&#40;</span>
			<span style="color: #3366CC;">'/subscription/url'</span><span style="color: #339933;">,</span>
			<span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>response<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>				
				$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'body'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span>response.<span style="color: #660066;">responseBody</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&lt;br&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>						
			<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
			$.<span style="color: #660066;">atmosphere</span>.<span style="color: #660066;">request</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>								
				transport<span style="color: #339933;">:</span> <span style="color: #3366CC;">'websocket'</span><span style="color: #339933;">,</span>
				fallbackTransport <span style="color: #339933;">:</span> <span style="color: #3366CC;">'long-polling'</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
	$<span style="color: #009900;">&#40;</span>window<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">load</span><span style="color: #009900;">&#40;</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>				
		setTimeout<span style="color: #009900;">&#40;</span>subscribe.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #CC0000;">500</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>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></div>

<p>The trick is: Wait for the whole page to be loaded (including all resources) by using $(window).load instead of $(document).ready. Then set a timeout to your subscription function. The timeout will change the execution context of the function to the global object (in most cases window). This needs to be corrected to the document for the atmosphere jQuery plugin to work. Here comes <em>bind()</em> to the rescue. This is a Javascript 1.8.5 function and it is not available in all browsers (see <a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function/bind">bind</a>) and therefore added to the prototype.</p>
<p>So far i&#8217;ve tested this in Firefox 3.6, Chrome 8, Safari 5 and Internet Explorer 8 and had no problems.</p>
<p class="akst_link"><a href="http://info.michael-simons.eu/?p=488&amp;akst_action=share-this"  title="E-mail this, post to del.icio.us, etc." id="akst_link_488" class="akst_share_link " rel="nofollow">Share This</a>
</p>]]></content:encoded>
			<wfw:commentRss>http://info.michael-simons.eu/2011/02/03/server-push-jquery-atmosphere-and-the-throbber-of-doom/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OS X Suchfelder in Safari</title>
		<link>http://info.michael-simons.eu/2006/05/01/os-x-suchfelder-in-safari/</link>
		<comments>http://info.michael-simons.eu/2006/05/01/os-x-suchfelder-in-safari/#comments</comments>
		<pubDate>Mon, 01 May 2006 09:19:22 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Safari]]></category>

		<guid isPermaLink="false">http://www.msimons.info/?p=13</guid>
		<description><![CDATA[Safari hat eine schöne Funktion. Trifft er im HTML Text einer Seite auf ein input Element vom Typ &#8220;search&#8221;, so stellt er es so dar: Der Inputtyp &#8220;search&#8221; ist allerdings nicht XHTML konform. Mit einem kleinen JavaScript, dass man beim onload des Bodies ausführt, bekommt gültiges XHMTL raus. Im XHTML Code der Seite ganz normal [...]]]></description>
			<content:encoded><![CDATA[<p>Safari hat eine schöne Funktion. Trifft er im HTML Text einer Seite auf ein <em>input</em> Element vom Typ &#8220;search&#8221;, so stellt er es so dar:</p>
<p><img id="image12" src="http://info.michael-simons.eu/wp-content/suchfeldsafari.thumbnail.jpg" alt="Suchfeld im Safari" /></p>
<p>Der Inputtyp &#8220;search&#8221; ist allerdings nicht XHTML konform. Mit einem kleinen JavaScript, dass man beim onload des Bodies ausführt, bekommt gültiges XHMTL raus.</p>
<p>Im XHTML Code der Seite ganz normal den Typ &#8220;text&#8221; notieren und eine Id vergeben:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;input type=&quot;text&quot; id=&quot;searchtextinput&quot; title=&quot;Suche&quot; name=&quot;s&quot;/&gt;&amp;#160;&lt;input type=&quot;submit&quot; value=&quot;go!&quot; /&gt;</pre></div></div>

<p>danach eine JavaScript Funktion mit folgendem Inhalt erstellen und onload ausführen:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> input <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;searchtextinput&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
input.<span style="color: #660066;">type</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;search&quot;</span><span style="color: #339933;">;</span></pre></div></div>

<p class="akst_link"><a href="http://info.michael-simons.eu/?p=13&amp;akst_action=share-this"  title="E-mail this, post to del.icio.us, etc." id="akst_link_13" class="akst_share_link " rel="nofollow">Share This</a>
</p>]]></content:encoded>
			<wfw:commentRss>http://info.michael-simons.eu/2006/05/01/os-x-suchfelder-in-safari/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress 2.0.x, Safari und der Visual Rich Editor</title>
		<link>http://info.michael-simons.eu/2006/04/22/wordpress-20x-safari-und-der-visual-rich-editor/</link>
		<comments>http://info.michael-simons.eu/2006/04/22/wordpress-20x-safari-und-der-visual-rich-editor/#comments</comments>
		<pubDate>Sat, 22 Apr 2006 11:05:46 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Safari]]></category>

		<guid isPermaLink="false">http://www.msimons.info/?p=4</guid>
		<description><![CDATA[Ein passender, erster seitenspezifischer Eintrag: Nachdem ich gerade ohne Probleme WordPress 2.0.2 mit dem wundervollen Tiger Style Administration Panel von Steve Smith eingerichtet habe, muss ich mich direkt drüber ärgern, dass auch dort im Safari unter Mac OS X der Default Visual Rich Editor von WordPress nicht angezeigt wird. Anscheinend führt der Visual Rich Editor [...]]]></description>
			<content:encoded><![CDATA[<p>Ein passender, erster seitenspezifischer Eintrag:</p>
<p>Nachdem ich gerade ohne Probleme WordPress 2.0.2 mit dem wundervollen Tiger Style Administration Panel von <a rel="external" href="http://www.orderedlist.com">Steve Smith</a> eingerichtet habe, muss ich mich direkt drüber ärgern, dass auch dort im Safari unter Mac OS X der Default Visual Rich Editor von WordPress nicht angezeigt wird.</p>
<p>Anscheinend führt der Visual Rich Editor im Safari direkt zu einem Totalabsturz. Leider funktionieren selbst die Quicktags nicht im Safari bzw. die Buttons erscheinen erst gar nicht.</p>
<p>Das allerdings kann man leicht ändern: Man braucht nur die Datei <em>admin-functions.php</em> im Verzeichnis <em style="font-style: italic">wp-admin</em> wie folgt anpassen:</p>
<p><span id="more-4"></span></p>
<p>Nach folgendem Textfragment suchen:</p>
<pre>if (!strstr($_SERVER['HTTP_USER_AGENT'], 'Safari'))</pre>
<p>Danach folgenden Text:</p>

<div class="wp_syntax"><div class="code"><pre class="php-brief" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Browser detection sucks, but until Safari supports the JS needed for this to work people just assume it's a bug in WP</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">strstr</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTP_USER_AGENT'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Safari'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #990000;">echo</span> <span style="color: #0000ff;">'
	&lt;div id=&quot;quicktags&quot;&gt;
		&lt;script src=&quot;../wp-includes/js/quicktags.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
		&lt;script type=&quot;text/javascript&quot;&gt;if ( typeof tinyMCE == &quot;undefined&quot; || tinyMCE.configs.length &lt; 1 ) edToolbar();&lt;/script&gt;
	&lt;/div&gt;
'</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">else</span> <span style="color: #990000;">echo</span> <span style="color: #0000ff;">'</span></pre></div></div>

<p>in diesen ändern</p>

<div class="wp_syntax"><div class="code"><pre class="php-brief" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Browser detection sucks, but until Safari supports the JS needed for this to work people just assume it's a bug in WP</span>
<span style="color: #990000;">echo</span> <span style="color: #0000ff;">'
&lt;div id=&quot;quicktags&quot;&gt;
	&lt;script src=&quot;../wp-includes/js/quicktags.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
	&lt;script type=&quot;text/javascript&quot;&gt;if ( typeof tinyMCE == &quot;undefined&quot; || tinyMCE.configs.length &lt; 1 ) edToolbar();&lt;/script&gt;
&lt;/div&gt;
'</span><span style="color: #339933;">;</span>
<span style="color: #990000;">echo</span> <span style="color: #0000ff;">'</span></pre></div></div>

<p>und fertig!</p>
<p class="akst_link"><a href="http://info.michael-simons.eu/?p=4&amp;akst_action=share-this"  title="E-mail this, post to del.icio.us, etc." id="akst_link_4" class="akst_share_link " rel="nofollow">Share This</a>
</p>]]></content:encoded>
			<wfw:commentRss>http://info.michael-simons.eu/2006/04/22/wordpress-20x-safari-und-der-visual-rich-editor/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 1.743 seconds -->

