Grails 0.6: Modifying JavaScript Libraries

September 19, 2007 by Michael

Grails has a good mechanism for including JavaScript Libraries to do all that fance Ajax stuff. It all starts with:

<g:javascript library="scripaculous" />

Library can be one of yahoo, prototype, dojo, scriptaculous or rico. It’s a nice fact, that Grails doesn’t force you to use any special of these.

I wanted to change the included javascript source files (I use yahoo and wanted to get the latest release from their servers). In Grails 0.5.6 the core plugins were copied to $APP_HOME/plugins and i could modifiy them inplace. Grails 0.6 cleaned up some stuff so that the core plugins do not flood into the application tree.

I could hack the Grails source files or i can just modify the static member LIBRARY_MAPPINGS in JavascriptTagLib while starting up the application like so:

BootStrap.groovy in $APP_HOME/grails-app/conf

class BootStrap {
     def init = { servletContext ->        
 + ['anylibrary_file_you_want.js', 'anylibrary_file_you_want2.js', 'etc.js']
     def destroy = {

Furthermore, Grails 0.6 introduced the “base” attribute to g:javascript. Base denotes the full path that is prepend to the library file in question. So its possible to use any js file from wherever you want.

No comments yet

Post a Comment

Your email is never published. We need your name and email address only for verifying a legitimate comment. For more information, a copy of your saved data or a request to delete any data under this address, please send a short notice to from the address you used to comment on this entry.
By entering and submitting a comment, wether with or without name or email address, you'll agree that all data you have entered including your IP address will be checked and stored for a limited time by Automattic Inc., 60 29th Street #343, San Francisco, CA 94110-4929, USA. only for the purpose of avoiding spam. You can deny further storage of your data by sending an email to, with subject “Deletion of Data stored by Akismet”.
Required fields are marked *