The reason we minimize / compress / combine for css / js / img is because we want to save network bandwidth and speed up application performance, reduce server load and make the user more happy.
When you put these groovy variables in your javascript code, you go to a different path, i.e. slow down the server. Since each request will receive a different javascript file to load, and the user will no longer use local cached copies of js. For the same reason, using greenscript or any other minimization tool for compression does not make sense, because each time you need to compress and combine again, and not get it directly from the cache.
If there are cases when you need to insert groovy variables into some javascript code, it is better to separate them from other parts (which should be reasonably larger than most). By doing this, you can still use greenscript or click to process your static js files and leave the dynamic parts in your view.
Gelin luo
source share