Search code examples
grailsyui

Grails YUI performance


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.

Does this behavior contradict the Yahoo rule of making JavaScript and CSS external?

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

Should I use the Grails UI performance plugin for that matter? Is there another way to do it?


Solution

  • Everything in software design is a trade-off.

    It depends on 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 and 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 one loop instead of having two meaningful loops, etc. (which is characterized as ugly code).