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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T00:31:59+00:00 2026-06-03T00:31:59+00:00

Why do scripts still run after their tags get removed? I was testing jQuery

  • 0

Why do scripts still run after their tags get removed?

I was testing jQuery to remove style and link tags to remove CSS styles when i accidentally typed ‘script’ instead of ‘style’ for the selector. But what happened is that the scripts defined in those tags still run. Why is that?

here’s a sample in JS:

//assume foo is defined
foo();

var scripts = Array.prototype.slice.call(document.getElementsByTagName('script')),
    current;

//remove all scripts
while (scripts.length) {
    current = scripts.pop();
    current.parentNode.removeChild(current);
}

//foo still works
foo();​

same thing with jQuery:

foo();

$('script').remove();

foo();​

And a side question: If they don’t get removed this way, what will?

  • 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-03T00:32:01+00:00Added an answer on June 3, 2026 at 12:32 am

    They run because they are loaded into memory when the script is first parsed.

    You can set anything to undefined to disable it.

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

Sidebar

Related Questions

Why is it that scripts can still function even after the code used to
Disclaimer: i still suck at writing scripts please be gentle if this is a
I'm working on a site that still has a lot of scripts in ColdFusion.
Can I run PowerShell scripts in an Silverlight application?
Does jQuery.ajax({async: false}) still use the XMLHttpRequest object? If so, how is the request
I have an application which get copied and run on client machines. The program
Here is what i want to do - run a series of jQuery animations
I am using JQuery to inject dynamically script tags in the body tab of
Related: How do I run different versions of jQuery on the same page? I
I have 3 scripts that do some stuff. I want to run them continously

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.