Hi,
which is better approach to store my JavaScript code, to store it in
separate .js file
or to embed the code within HTML attributes (e.g. <p
onclick="javasc ript:submit();" >click this</p>)?
I am interested in performance, i.e. how quick is page loaded in each case?
I think the better one is to store the code in separate .js file so that the
user browser can cache the file
(source: http://www.quirksmode.org/js/placejs.html#link1) but I am not
entirely sure.
Thanks in advance.
--
Slavo Smutny 1 2403
Slavo Smutny wrote on 21 nov 2005 in comp.lang.javas cript: Hi, which is better approach to store my JavaScript code, to store it in separate .js file or to embed the code within HTML attributes (e.g. <p onclick="javasc ript:submit();" >click this</p>)?
onclick="javasc ript:submit();"
is always wrong because superfluous, use:
onclick='submit ();'
You cannot put the above in a .js file however.
perhaps you mean: <script ..></script> ?
I am interested in performance, i.e. how quick is page loaded in each case?
Did you test it?
I think the better one is to store the code in separate .js file so that the user browser can cache the file (source: http://www.quirksmode.org/js/placejs.html#link1) but I am not entirely sure.
The catching is true, but "better" depends on the file-size, the importance
of loading time, and the effect on server use amount.
In general the first reason to have a .js file is using that same file for
multiple pages, IMHO, with many advantages, like the ones above, but also
disadvantages, like extensive testing when you change the file.
--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Rick |
last post by:
Hi.. I've got some code I wrote in PHP that will generate an HTML page
with embedded javascript which in turn creates a new argument
string for the browser, but the xhtml parser in Firefox and Opera both
complain about my use of &var=value pairs in the generated URL.
Below is my code that generates the string, and is part of an embedded
HTML page (generated on the fly by a PHP script):
function InvokeURL(url_to_forward_to)
{
|
by: David D. |
last post by:
Does the file extension matter when including a JavaScript file in an HTML
page?
Normally, one would include a JavaScript file in an HTML page using
<script src="foo.JS" type="text/javascript">
However, I have found that I can use an alternate file extension, such as
<script src="foo.HTML" type="text/javascript">
It works fine with my IE 6 and Mozilla. Will it work with other browsers?
|
by: Robert Oschler |
last post by:
I have a web page that has portions of it created by Javascript during the
document load, through the use of "document.write()" statements.
I can get the contents of the document via the
"document.documentElement.innerHTML" property, but that property contains
the portions created by the Javascript "document.write()" statements.
I would like to get a copy of my web before the "document.write()"
statements occur.
|
by: RFS666 |
last post by:
Hello,
I would like to use variables with a type in jscript.NET.
I declare them as follows:
var x : double = 5.03;
This doesn't work in my script, that I write to the page in codebehind with
"registerClientScriptBlock" as follows:
string script = "<script language=jscript>";
script += "function test()";
|
by: Tudor Tihan |
last post by:
Hi,
This is my first post here, so please be kind.
I have tryed to make a javascript html page loader by using an
invisible <IFrame> and some javascript variable text passing between
entities.
This seems to brake the CSS after some depth, or perhaps I am not
understanding something.
| |
by: kelvlam |
last post by:
Hello,
I'm a new begininer with JavaScript. I'm trying to figure out which is
the best approach, and to understand the differences between them.
I have a <Aelement that's suppose to either launch a popup window, or
it will link you to some dynamic created page.
I have declared a global JavaScript function
|
by: Jake Barnes |
last post by:
I did a search on the newsgroup comp.lang.javascript. I was searching
for "how to play a sound with Javascript". I'm somewhat suprised that
the majority of entries are from the 1990s, and there are almost no
posts from the last 3 years:
http://groups.google.com/group/comp.lang.javascript/search?group=comp.lang.javascript&q=how+to+play+a+sound+with+Javascript&qt_g=Search+this+group
Even after sorting by date, there don't appear any...
|
by: maya |
last post by:
hi,
so what is "modern" javascript?? the same as "DOM-scripting"? i.e.,
editing content (or changing appearance of content) dynamically by
massaging javascript objects, html elements, etc? (in conjunction with
css, you know, the usual...;) this is what is meant by "modern"
javascript?? so how do folks feel about this who think javascript is so
evil they disable it from their browsers?? do sites designed with
"modern" javascript...
|
by: humtum |
last post by:
Greetings Everyone!
I am working on a Java application where I have to develop a Swings client which talks to a web-server. The client sends the HTTP get request for a specific resource which it receives as HTML and uses JEditorPane to render the HTML.
The overall architecture is like I have a HTML request processor thread which connects to a particular URL and GETs the resource. The resource is a "String" which contains the HTML. Now is...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |