How can I put this javascript in external .js file?

  • Thread starter Thread starter Jeff
  • Start date Start date
J

Jeff

hi

asp.net 3.5

When I view the source of my site I see some javascript generated in the
html:
<script type="text/javascript">
//<![CDATA[
var theForm = document.forms['aspnetForm'];
if (!theForm) {
theForm = document.aspnetForm;
}
function __doPostBack(eventTarget, eventArgument) {
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.value = eventTarget;
theForm.__EVENTARGUMENT.value = eventArgument;
theForm.submit();
}
}
//]]>
</script>
Wonder if I could remove this javascript from the page and put in a .js
file? I wonder how to do that?This is not like any other javascript I know
about, this javascript is generated in the html output from the webserver.So
I suppose some technique must be implemented which stop the html output from
generating the javascript if the javascript instead existsin a .js
file....Any suggestions?
 
hi

asp.net 3.5

When I view the source of my site I see some javascript generated in the
html:
<script type="text/javascript">
//<![CDATA[
var theForm = document.forms['aspnetForm'];
if (!theForm) {
    theForm = document.aspnetForm;}

function __doPostBack(eventTarget, eventArgument) {
    if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
        theForm.__EVENTTARGET.value = eventTarget;
        theForm.__EVENTARGUMENT.value = eventArgument;
        theForm.submit();
    }}

//]]>
</script>
Wonder if I could remove this javascript from the page and put in a .js
file? I wonder how to do that?This is not like any other javascript I know
about, this javascript is generated in the html output from the webserver..So
I suppose some technique must be implemented which stop the html output from
generating the javascript if the javascript instead existsin a .js
file....Any suggestions?

This is a postback handler which is generated automatically by .NET.
Why do you need to move it out of html?
 
I use Page Speed in FireFox and it gives me 4 issues I should do something
about to improve site performance.
One of them is to put javascript in external file. I suppose Page Speed is a
product of Google? It's a bit hard to satisfy Page Speed, it says also that
the best would have been if I put all javascript + all the javascript from
my adsense adverts into an external file... which is impossiple - I don't
have access to Google adsense source code.

So I suppose I cannot put it a external file, right? I think it's unlikly to
give some performance gain. But it was some of the issues which I easily
could implement. Things like enable compression, leverage proxy caching,
leverage browser caching is a bit harder to implement on IIS6 on shared
hosting. Have asked the host if he could configure browser caching. But they
couldn't cause of shared hosting. Not satisfied with the host, as my site
got hacked and they had no idea how .php files could be uploaded to my
webdirectory. These .php files had some scripts which stopped my site from
working. My site displayed a blank page asking for IISPassword...

Also my site has dropped from #40 to #700 and is looking for ways to improve
it's serp...




hi

asp.net 3.5

When I view the source of my site I see some javascript generated in the
html:
<script type="text/javascript">
//<![CDATA[
var theForm = document.forms['aspnetForm'];
if (!theForm) {
theForm = document.aspnetForm;}

function __doPostBack(eventTarget, eventArgument) {
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.value = eventTarget;
theForm.__EVENTARGUMENT.value = eventArgument;
theForm.submit();
}}

//]]>
</script>
Wonder if I could remove this javascript from the page and put in a .js
file? I wonder how to do that?This is not like any other javascript I know
about, this javascript is generated in the html output from the
webserver.So
I suppose some technique must be implemented which stop the html output
from
generating the javascript if the javascript instead existsin a .js
file....Any suggestions?

This is a postback handler which is generated automatically by .NET.
Why do you need to move it out of html?
 
Jeff said:
I use Page Speed in FireFox and it gives me 4 issues I should do
something about to improve site performance.
One of them is to put javascript in external file. I suppose Page
Speed is a product of Google? It's a bit hard to satisfy Page Speed,
it says also that the best would have been if I put all javascript +
all the javascript from my adsense adverts into an external file...
which is impossiple - I don't have access to Google adsense source
code.

Removing that tiny bit of Javascript will make, at most, a tiny, tiny
difference. Removing all occurrences of CR will make more difference.

For performance, the biggest improvement would be to remove the adsense
adverts.
Also my site has dropped from #40 to #700 and is looking for ways to
improve it's serp...

If your site has become sentient, your worries are over anyway :-)

Have you seen Google's ideas about SEO?
http://www.google.com/support/webmasters/bin/answer.py?hl=en&answer=35291

And don't forget that there are other search engines, many of which also
offer free advice and tools.

Andrew
 
Jeff said:
hi

asp.net 3.5

When I view the source of my site I see some javascript generated in the
html:
<script type="text/javascript">
//<![CDATA[
var theForm = document.forms['aspnetForm'];
if (!theForm) {
theForm = document.aspnetForm;
}
function __doPostBack(eventTarget, eventArgument) {
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.value = eventTarget;
theForm.__EVENTARGUMENT.value = eventArgument;
theForm.submit();
}
}
//]]>
</script>
Wonder if I could remove this javascript from the page and put in a .js
file? I wonder how to do that?This is not like any other javascript I know
about, this javascript is generated in the html output from the
webserver.So I suppose some technique must be implemented which stop the
html output from generating the javascript if the javascript instead
existsin a .js file....Any suggestions?

This JavaScript is dynamically added to the HTML page content by the script
hanlder resource that runs in IIS - - it cannot be separated out from an
..aspx page. What you have read about placing scripts into external .js
files/libraries *can* help increase performance, but for something like
this, you'd never notice any change whatsoever.

-Scott
 
I use Page Speed in FireFox and it gives me 4 issues I should do something
about to improve site performance.
One of them is to put javascript in external file. I suppose Page Speed is a
product of Google? It's a bit hard to satisfy Page Speed, it says also that
the best would have been if I put all javascript + all the javascript from
my adsense adverts into an external file... which is impossiple - I don't
have access to Google adsense source code.

So I suppose I cannot put it a external file, right? I think it's unliklyto
give some performance gain. But it was some of the issues which I easily
could implement. Things like enable compression, leverage proxy caching,
leverage browser caching is a bit harder to implement on IIS6 on shared
hosting. Have asked the host if he could configure browser caching. But they
couldn't cause of shared hosting. Not satisfied with the host, as my site
got hacked and they had no idea how .php files could be uploaded to my
webdirectory. These .php files had some scripts which stopped my site from
working. My site displayed a blank page asking for IISPassword...

Also my site has dropped from #40 to #700 and is looking for ways to improve
it's serp...


asp.net 3.5
When I view the source of my site I see some javascript generated in the
html:
<script type="text/javascript">
//<![CDATA[
var theForm = document.forms['aspnetForm'];
if (!theForm) {
theForm = document.aspnetForm;}
function __doPostBack(eventTarget, eventArgument) {
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.value = eventTarget;
theForm.__EVENTARGUMENT.value = eventArgument;
theForm.submit();
}}
//]]>
</script>
Wonder if I could remove this javascript from the page and put in a .js
file? I wonder how to do that?This is not like any other javascript I know
about, this javascript is generated in the html output from the
webserver.So
I suppose some technique must be implemented which stop the html output
from
generating the javascript if the javascript instead existsin a .js
file....Any suggestions?

This is a postback handler which is generated automatically by .NET.
Why do you need to move it out of html?

The script is added because of the server-controls with postback
functionality. Read this for more information:
http://www.xefteri.com/articles/show.cfm?id=18

Hope this helps
 
Back
Top