473,396 Members | 1,914 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Removing JavaScript from the document.

Daz
Hi everyone.

I would like to know if it's possible to clean up my scripts, or if you
will, 'make them biodegradable'. Some of my smaller script will be
download to the users browser, but I would like to clear them once I am
done, so as not to bog down the browser more than needed. I have tried
removing the script element, and/or setting the src attribute to null
and '', but the script itself still remains.

Here is some example code.

<head>
<script id="remove_me" type="text/javascript">
function foo(){
alert("bar!");
}
</script>
<script type="text/javascript">
function removeScript(){
script = document.getElementById('remove_me');
script.src = "";
script.parentNode.removeChild(script);
delete script;
}
</script>
</head>
<body onload="removeScript();"><body>
</html>

Note that there is no colsure created in this script, so the script
should be removed. But when I call upon foo() from the JavaScript
console in Firefox, it's still there!

Would anyone know how I can remove the entire script from RAM?

Many thanks.

Daz.

Jan 14 '07 #1
2 1355
ASM
Daz a écrit :
Hi everyone.

I would like to know if it's possible to clean up my scripts, or if you
will, 'make them biodegradable'. Some of my smaller script will be
download to the users browser, but I would like to clear them once I am
done, so as not to bog down the browser more than needed. I have tried
removing the script element, and/or setting the src attribute to null
and '', but the script itself still remains.
to delete, remove the scripts or to try to pass its src to 'none' or to
empty, is of no interest because when you call that it is too late : the
scripts have been downloaded

Or you have a post-loader for your scripts

Or you re-define all loaded variables and functions to ''
--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Jan 14 '07 #2
Daz

ASM wrote:
Daz a écrit :
Hi everyone.

I would like to know if it's possible to clean up my scripts, or if you
will, 'make them biodegradable'. Some of my smaller script will be
download to the users browser, but I would like to clear them once I am
done, so as not to bog down the browser more than needed. I have tried
removing the script element, and/or setting the src attribute to null
and '', but the script itself still remains.

to delete, remove the scripts or to try to pass its src to 'none' or to
empty, is of no interest because when you call that it is too late : the
scripts have been downloaded

Or you have a post-loader for your scripts

Or you re-define all loaded variables and functions to ''
--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Thanks for that. Deleteing the var that contains the data makes
complete sense. I don't know why I didn't think of it. Doh! Perhaps
it's been a long day... :)

Daz.

Jan 14 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: ASP.Confused | last post by:
I am designing a forum system, and I would like to know if there is a script somewhere that can parse an HTML response, and remove javascript. I would like to do this so that I don't have hackers...
1
by: nickolausp | last post by:
When embedding a JavaScript document.write within a JavaScript document.write in Netscape 4.x (example below), the text is written out of logical order. <script type="text/javascript"> <!--...
2
by: Brett Baisley | last post by:
Hello I have a block of html code that I want to run by calling a javascript function to print it. Its basically a table with menu items in it that is the same for many pages, and instead of...
2
by: Miles Davenport | last post by:
My Javascript is rather rusty :( ... and I need to do change some form values, in the folowing way: (1). I have the following a href (wrapped in PHP), which calls processForm. ==== <input...
1
by: Leila | last post by:
Folks I have an html file which looks like this: .. .. .. <body onLoad="WindowOnLoad();"> .. ..
8
by: bradwiseathome | last post by:
I have code that works in IE 6 but does not work in FireFox 1.0.2, how can I change it so it works in both browsers? <html> <head> <script language="JavaScript" type="text/JavaScript">...
4
by: dschruth | last post by:
Hello. Can anybody solve this problem? I am using a server-side language (PERL) to *try* to POST data to a HTTPS login script that doesn't have a standard "submit" button. The form appears...
1
by: bonnie.tangyn | last post by:
Hello all Would it be possible to store javascript document.forms.value to ASP session as global variable? If it is not possible, how can I pass the javascript document.forms.value to...
2
by: bonnie.tangyn | last post by:
Hello all Would it be possible to store javascript document.forms.value to ASP session as global variable? If it is not possible, how can I pass the javascript document.forms.value to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.