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

  • Home
  • SEARCH
  • 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 6364055
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:06:57+00:00 2026-05-25T00:06:57+00:00

I am using jQuery to dynamically add a script to my page and it

  • 0

I am using jQuery to dynamically add a script to my page and it works, but jQuery appends “_=TIMESTAMP” to the URL causing the browser to never use the cache. With the following code:

<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
</head>
<body>
    <script type="text/javascript">
        $("head").append('<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.15/jquery-ui.min.js"></scr' + 'ipt>');
    </script>
</body>
</html>

I can see in firebug that the URL requested is:

https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.15/jquery-ui.min.js?_=1313291978667

Does anyone know how to tell jQuery not to do this?

Thanks

  • 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-05-25T00:06:58+00:00Added an answer on May 25, 2026 at 12:06 am

    To answer your original question, you see the timestamp appended because jQuery by default sets cache: false for script and jsonp calls which appends the timestamp to the URL.

    To avoid the timestamp, you can do this:

    $.ajaxPrefilter(function( options, originalOptions, jqXHR ) {
      if ( options.dataType == 'script' || originalOptions.dataType == 'script' ) {
          options.cache = true;
      }
    });
    

    This sets up a global prefilter for all $.ajax calls, including the ones made by jQuery while requesting the script.

    We inspect the dataType to make sure we’re not inadvertantly targetting other ajax calls and explicitly set cache to true. This will avoid the timestamp appending problem.

    You can now use your original code and it’ll pick it up from cache.

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

Sidebar

Related Questions

I'm using jQuery to dynamically add two divs on page load. It all works
I am using Jquery to dynamically add some HTML into a page. Now this
I'm using jQuery to let users dynamically add and remove form fields, but it's
I'm using jQuery to dynamically add new divs containing a few fields. I'm adding
i am dynamically creating radio using jquery as shown belown. but they value only
I have a problem with dynamically added script element (using jQuery). Code for adding
I am using JQuery to dynamically add a link for an image file. +
i am using jQuery to dynamically add content $(#articles).prepend('<article><header><p>info</p><h2>You are using Internet Explorer</h2></header><p>It is
I'm using jQuery to dynamically add rows to my HTML table on a button
I'm using jQuery to dynamically add form elements to a web form. Users can

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.