Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7791207
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T21:48:55+00:00 2026-06-01T21:48:55+00:00

In my grails app, we use jquery. I include jquery on the necessary pages

  • 0

In my grails app, we use jquery. I include jquery on the necessary pages with

<g:javascript library="jquery"/>

If we decide to change javascript libraries, I need to update every page. I know I can include this in the layout, but the library is not needed on every page, so that seems wasteful.

Is there a typical way in grails to specify in one place what the default javascript library should be and then to just include that default one without specifying that it is jquery (or whatever it is) on every page?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T21:48:56+00:00Added an answer on June 1, 2026 at 9:48 pm

    Since most browsers heavily cache things like JavaScript libraries, putting the library include into the layout is probably better than putting it in each individual page. The heavy caching that browsers do means that users will only load the library from the server once for your whole site (or at least their browsing session), and by having it be handled in the layout you are drastically reducing your maintenance load (which you alluded to)

    In general, your JavaScript libraries should be highly cached, and in many cases it’s preferable to pull them from a highly used CDN, like Google’s. Your “local” (ie. from your server) library should only get requested if the CDN provider goes down and the browser can’t get to their library. (Take a look at the HTML5Boilerplate project for how this is done)

    Because of that, I wouldn’t worry about the very minimal performance hit that putting the library into the layout page would incur. Even if you don’t use a well-used CDN for your library, any browser that people actually use today will only load your JavaScript library once (the first page it gets that includes it) and will simply use it’s cached copy for the rest of the pages on your site.

    So, in a nutshell, put it in the layout page and don’t worry about it. It will only be requested on the first page load, and will come from the cache for all subsequent loads, and your codebase will be DRYer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My current requirement is: I have to package my grails app and use teamcity
I have a grails 1.2 app and I want to use declarative security in
For my Grails App i use Searchable Plugin to have an nice google-like Search.
I need some help dealing with timeouts in a Grails app. Context: In my
I am working on a grails app and need to remove Tomcat plugin in
Has anyone used Maven , Grails , and App Engine together? I can use
In my Grails app I use session.invalidate() to deal with a timeout. When a
I use the Grails CloudFoundry plugin to deploy my Grails app. Almost as soon
I need to use EJB remote calls from my grails application. For this in
I have a grails app configured with spring-security-core and I need to allow Facebook

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.