Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Removing JavaScript from the document.

Reply
Thread Tools

Removing JavaScript from the document.

 
 
Daz
Guest
Posts: n/a
 
      01-14-2007
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.

 
Reply With Quote
 
 
 
 
ASM
Guest
Posts: n/a
 
      01-14-2007
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
 
Reply With Quote
 
 
 
 
Daz
Guest
Posts: n/a
 
      01-14-2007

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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Removing GPO setting from XP machine after removing from Domain Piet Slaghekke Computer Support 4 01-02-2007 08:58 PM
removing a namespace prefix and removing all attributes not in that same prefix Chris Chiasson XML 6 11-14-2006 05:08 PM
Removing a form using JavaScript+DOM francescomoi@usa.com Javascript 2 08-15-2005 07:15 PM
removing a listbox item - javascript RA ASP .Net 0 11-15-2004 06:24 PM
removing javascript from a HTML file dynamically ASP.Confused ASP General 3 07-28-2004 03:27 PM



Advertisments