Latest jQuery with Grails 2 and the resources plugin

von Florian Mutter

We just updated the front end of an older Grails 2.1.5 application to Bootstrap.

The application uses the resources plugin and due to some other dependencies the jQuery plugin is loaded. The jQuery plugin ships with jQuery 1.11.1 and was not updated since 2014. The latest jQuery version as of now is 2.2.3. So how can we update the javascript library without fiddling with dependency excludes or other hacks?

The resources plugin lets you override single resource files that are loaded in a plugin. The only thing you need is the id of the resource. In this case we have the following definition in the Grails jQuery plugin:

modules = {
    'jquery' {
        resource id: 'js',
                 url: [plugin: 'jquery', dir: 'js/jquery', file: "jquery-${jqver}.min.js"],
                 disposition: 'head', nominify: true
    }
    [...]
}

The id for the javascript file is 'js'. The new jQuery version was put in web-app/lib/jquery-2.2.3. With the following override in the ApplicationResources.goorvy configuration the latest jQuery version is used everywhere:

modules = {
    overrides {
        'jquery' {
            resource id: 'js', url: 'lib/jquery-2.2.3/jquery-2.2.3.js'
        }
    }
    [...]
}

This is a simple and fast way to override any javascript or css file that is provided by a Grails plugin. The documentation of the resources plugin has some more informations about overrides.

Zurück

© 2006-2024 exensio GmbH
Einstellungen gespeichert
Datenschutzeinstellungen

Wir nutzen Cookies auf unserer Website. Einige von ihnen sind essenziell, während andere uns helfen, diese Website und Ihre Erfahrung zu verbessern.

Sie können Ihre Einwilligung jederzeit ändern oder widerrufen, indem Sie auf den Link in der Datenschutzerklärung klicken.

Zu den gesetzlichen Rechenschaftspflichten gehört die Einwilligung (Opt-In) zu protokollieren und archivieren. Aus diesem Grund wird Ihre Opt-In Entscheidung in eine LOG-Datei geschrieben. In dieser Datei werden folgende Daten gespeichert:

 

  • IP-Adresse des Besuchers
  • Vom Besucher gewählte Datenschutzeinstellung (Privacy Level)
  • Datum und Zeit des Speicherns
  • Domain
You are using an outdated browser. The website may not be displayed correctly. Close