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 9208303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:35:12+00:00 2026-06-18T00:35:12+00:00

Twofold question. Using a web template that utilizes AJAX for loading new pages, rather

  • 0

Twofold question.

Using a web template that utilizes AJAX for loading new pages, rather than traditional point-the-browser-to-the-url style, how would one go about adding new script or style tags to the page head as necessary?

I think using jQuery $(‘head’).append(script); works just fine, but (and here’s the second half), if I wanted to group all of the scripts that were page-dependent away from those that are universal across the site – how would I do that?

Using a div sounds so enticing since I could print it at the initial page render and just call
$('head div.external').append(script), but still probably a bad idea inside the head.

Is there any other element or method I could use to group these? The goal being to easily remove all of them when the user navigates away from the current page. A smaller consideration is that Google Analytic instructs you to place it at the end of the head tag (I’ll be honest, I don’t know why being the last script matters), and I don’t want my scripts to interfere. Do these even need to be in the head, could I place a div at the end of the body and use that?

  • 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-18T00:35:13+00:00Added an answer on June 18, 2026 at 12:35 am

    Surely the easiest way to do this, if it is necessary, is with classes:

    $(script).addClass('external').appendTo('head');
    

    then later:

    $('script.external').remove();
    

    I’m honestly not sure what this would achieve, however.

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

Sidebar

Related Questions

This compojure question is twofold! How can I display an image object in a
We're developing a new eCommerce website and are using NHibernate for the first time.
We're a web development shop using PHP or .Net. Here's the proposed path for
This is probably a question that has been asked before, but I couldn't find
All, Question 1 while using templates, Compiler error information is known to be very
Suppose I have a class that downloads a news feed from the web public
I recently joined a new team. This team has been using Subversion for their
This might be a duplicate question as I have found a few that are
I'm trying to consume a hello world AXIS2 SOAP web service using a PHP
As the question states, I am trying to get a Path value, using JFileChooser.

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.