tags:

views:

146

answers:

2

Using the grails YUI plugin I've noticed that my gui tags are replaced with some javascript code that is inserted in the HTML page.

Is this behavior contradicts the Yahoo rule of Making JavaScript and CSS External? (http://developer.yahoo.com/performance/rules.html)

In other words, how do I separate the script code from the HTML page in order to allow external js script caching?

Should I use the grails ui performance plugin (http://grails.org/plugin/ui-performance) for that matter? is there any other way to do it?

Thanks, Guy

A: 

Well, this is one the features of the UiPerformance Plugin amongst other things:

The UI Performance Plugin addresses some of the 14 rules from Steve Souders and the Yahoo performance team.

[...]

Features

  • minifies and gzips .js and .css files
  • configures .js, .css, and image files (including favicon.ico) for caching by renaming with an increasing build number and setting a far-future expires header
  • [...]

So I'd use it indeed.

Pascal Thivent
A: 

Everything in software design is a trade-off.

Depends if the benefit of performance overweights the importance of having well segregated and maintainable code.

In your case, I wouldn't mind having some extra javascript code automatically added to dramatically improve the performance.

Complete code/ui separation always comes at a price. More levels of abstraction and intermediate code often translates into slower performance but better maintainability.

Sometimes, the only way to reach maximum efficiency is to throw away all those abstractions and write optimized code for your platform, minimizing the number of functions and function calls, trying to do as most work as possible in 1 loop instead of having 2 meaningful loops, etc (which is characterized as ugly code).

Wadih M.