Eval And Mutireplace, Which Is Faster?
Dec 26, 2006I want to implement the template for a object output. I have two methods as follow:
View 1 RepliesI want to implement the template for a object output. I have two methods as follow:
View 1 RepliesI have a problem on my current project. Animations are very slow on IE8 but when I turn the compatibility mode on, it become very fast.
FF, Safari and Chrome run it fast too. I don't understand how my site can be slower on IE8 than on IE7 O_o
I'm trying to select client side language to learn. For some time i wanted to learn Javascript, but when i tried writing first script which was so simple, i saw that it has so much problems. I thought of flash, and read few tutorials online. It's pretty simple but powerful language.
I know that probably worst feature of flash is that it's not included by default in your browser, but since youtube and other video sharing services i think that flash players on browsers are drastically more installed then before, and that almost everybody has it.
Now, i'm planning to create chat for my personal website, and i saw Ajax chats, and Flash chats. Since i don't have experience with any of the scripts i'm wondering which code is faster Properly written Javascript, or Actionscript.
Also, which of these languages are better for me to learn. I'm learning web programming as hobby so don't use money as argument. But which of those two can be used for creating fun, dynamic, fast and safe programs easily
I've developed a calendar program in javascript, and up until now I've
done most of my testing using Mozilla and Firefox. Everything works
fine, but when I try to use Internet Explorer my response time is
sometimes 50 times slower than using Mozilla.
I know I haven't given you much to go by, but I'm not looking for an
answer so much as an approach to debugging the problem. For example,
does anyone here know of a good web site which deals with
browser-specific javascript performance issues?
How do I make my Script load faster?
Is there Code that will make my Script load faster,
(so that it won't take so long to view)
If so, can someone show me how to incorporate it into my Example Script
I am currently doing a photography site.I would like to do a 'portfolio' page, but would like to pre-load the images so that they appear on-screen faster.Do I need to connect code to <body onload>?
View 22 Replies View RelatedI'd like to know which is faster or have a better performance between :
Code JavaScript:
if (flag) {
var v = "something";
} else {
var v = "else";
[Code]...
I built up 2 codes, which do the same cause. but which one would be most efficient? or maybe which one would be best compatible for browsers?
CODE 1 :
- this code allows for me to use an #id
CODE 2
- using the REL
works ok, but my alert box comes in really slowly, then bounces. I want it to appear faster and to also appear after exactly one hour. I don't think that works right either. What do I need to change in order to do this?
[Code]...
Is it possible using slideToggle to set a faster speed for hiding than for showing?
View 4 Replies View RelatedI'm writing a blog post that uses multiple videos from YouTube and Yahoo Video, but I'm not happy with how long it takes the page to render. Apart from using an ajax-y method to load the videos, are there any tricks that would make the page load quicker with multiple videos from different sources?
View 6 Replies View RelatedAnyone loading a bunch of CSS or Javascript via <link> tags on a web page knows about "blocking": where the browser stops the loading of the page because it has to go fetch (and read/parse) an external file. If you have a lot of these, or even if you don't and the user has a slow connection, you have a slow page. Users hateses teh slow pages, hatses them.
At the 2010 Fronteers Conference, Stoyan Stefanov gave a talk on Progressive Downloads and Rendering, where he listed some tricks to get around blocking by Javascript or other external files to make page load speed up. One trick was adding a <script> tag in the body (near the bottom, so after the important stuff has loaded) which adds a <script> tag to the <head> dynamically and runs it. While that file is being fetched, the rest of the page can continue to load. This is a bit asynchronous, isn't it (similar to web pages still loading content while also fetching images)?
As a follow-up to his Higher Order Javascript article (see SitePoint thread about it), Piers Cawley has gone further with Asynchronous Streams, where he uses jQuery (as an example) to load external files asynchronously to avoid blocking of the HTML document loading. In my web development career I haven't worried about blocking, but plenty of folks around here are loading ginormous files, and lots of them, for large sites. As developers, what do you do to get around slow page loads? Have you done anything like this asynchronous calling of the external files?
given that I have a js file included which is written programatically and I
can't change it. I would like to know how to do the following using
something other than the deprecated eval().
whats in the js file
var numArrays=something;
var data0 = new Array();
data0.name="name";
data0.data="some data";
var data1 = new Array();
data1.name="another name";
data1.data="some more data";
etc ....
function getData(arrayName) {
for ( var i=0;i<numArrays:i++) {
var el=eval('data'+i);
if (arrayName = = el.name) doSomething(el.data);
}}
var fns = ['orde', 'no', 'kml', 'snf', 'td', 'ty', 'tn', ...up to 21
elms...];
var snv = new Array();
var vals = new Array();
for (i = 0; i < N; i++) {
for (j = 0; j < fns.length; j++)
vals[j] = some value;
snv[i] = new makeData(vals);
}
function makeData(vals) {
for (k = 0; k < vals.length; k++)
//the following line doesn't work
eval("this."+fns[k]+"="+vals[k]);
//neither this one
this.eval(fns[k]) = vals[k]);
}
how can i make it without writing it the long way:
this.orde = vals[0];
this.no = vals[1];
this.kml = vals[2];
and so on?
how comes the following doesnt work
fieldNotes2=eval("Message.notes["+id2+"]");
i believe it's because of the [] but i need to keep them!
I've made a funny program using eval()...it will let the person(on the page) to write javascript and have it compile(if thats the right word for it)! its quite cool, i dont know how handy it might be, but here it is none the less...
code:
<html>
<head>
<title>test</title>
<script language="JavaScript">
function submitCode(){
var the_code = window.document.form_1.textarea_1.value;
var run_the_code=eval(the_code);
}
</script>
</head>
<body>
<center>
<h1>write some code!</h1>
<form name="form_1">
<textarea name="textarea_1" rows=10 cols=40>
</textarea>
</form>
<form onSubmit="return false;">
<input type="submit" value="submit your code" onClick="submitCode();">
</form>
</center>
</body>
</html>
very simple stuff, but for those of you who are unfamilir with eval, its pretty cool, huh?
I'm having some weird problem with evaluating the continue statement.
Within a for loop I'm trying to evaluate a string (generated somewhere
earlier) which basically has the continue statement in it. IE6 seems to
have major problems with that as it generates an error "Can't have
'continue' outside of loop". Does anyone know why and/or have a
workaround? I haven't tried any other browser since this one is the
only one available (company policy).
I have included some code to reproduce this behaviour. The first and
second if statements of the testeval function behave as expected. The
third one however produces the mentionned error. Code:
I am trying to do the following but i get an error, is there no way i
can use eval to print have it assigned to a predeterminded variable.
eval (object_name + "_CalCalendar") = new CalendarPopup(object_name);
Cannot assign to function result.
Here is my code.
function CallDisplay()
{
nodeobj=new mynode();
x="displayId("+nodeobj+")";
eval(x);
}
function displayId(node)
{
alert(node.myid);
}
function mynode()
{
this.myid="aa";
}
In CallDisplay() I am getting the error as "Microsoft JScript
Compilation error ']' expected". Any one can suggest me how to
overcome this.
I'm running some javascript over a server side generated web page
and have multiple generated empty select statements, that I want to
populate when the page is loaded. As HTML doesn't do arrays each
select is individually named withe MySelecti where i is an incremental
from 1.
I know all my variables are correct (i, OptionsCount) and my arrays
of MyValues and MyDescription's exist for multiple enteries and if I
bring out an example of what I thought each line would eval too( say
document.MyForm.MySelect1.options[1]=new
Option('Value1','Description1') the line works fine, for the life of me
(i'm sure I'm missing something obvious) the eval line won't eval..
for(i = 1; i<=row; i++) {
for (j = 1; j <=OptionsCount; j++) {
eval="document.MyForm.MySelect"+i+".options["+j+"]=new
Option('"+MyValues[j]+"', '"+MyDescription[j]+"')";
eval(eval);
}
}
I am trying to assign an "onclick" event to a dynamically-created DOM
element (an image).
I have read countless times that "eval()" is to be avoided at all costs.
However, I cannot seem to get my new onclick to work without it.
Here's what I have so far:
myeval = 'detachFile(this);'
detachImage = getElementById('detach-jfhahhf');
detachImage.onclick = function() { eval(myeval) }
This works perfectly fine for me, but this is a web-app that will be
exposed to public users, and I obviously don't want them being able to
eval anything if i can help it.
Can that be done without the eval()?
i came up with the following, to help me test the syntax of functions while i'm writing them. i've only been using it for a day or two, but so far, it's been really handy.
<HTML>
<HEAD>
<TITLE>Evaluator</TITLE>
<META HTTP-EQUIV="Content-Script-Type" CONTENT="text/javascript">
</HEAD>
<BODY>
<FORM>
<TABLE WIDTH="100%" HEIGHT="100%">
<TR>
<TD COLSPAN="2" HEIGHT="100%"><TEXTAREA NAME="script" STYLE="width: 100%; height: 100%"></TEXTAREA></TD>
</TR>
<TR>
<TD ALIGN="CENTER"><INPUT TYPE="BUTTON" VALUE="eval" OnClick="eval(this.form.script.value);"></TD>
<TD ALIGN="CENTER"><INPUT TYPE="RESET" VALUE="clear"></TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>
In Visual Basic this is easy to do, but I'd like to do it in JavaScript (without writng my own).
I'd like to put a text box on a form so the user can type something like:
3+5*(sin(90))^2
and have the answer to the equation displayed.
I guess it would be possible to translate it into a javascrip command
x=Math.pow(3+5*(Math.sin(90)),2) and then execute the translated line using Eval(x);, but maybe there's an easier way. Any thoughts?
I have a script that will loop through all the INPUT elements of a form; if the input is a submit it will disable the submit (or enable the submit, depending upon what is passed to the function.) I hate using eval() - I avoid it whenever I can! Is there a better way to dynamically process the ".disabled = 'true'/'false';" portion?
[Code]..
this is the code I'm working on:
Code:
var tabs = new Control.Tabs('menu');
var pattern = 'tab=';
var nStr = location.href;
if(nStr.match(new RegExp (pattern,'gi'))){
var id = nStr.split(pattern);
[Code]...
It searches for the query string 'tabs=' and then splits the result to get the id of the tab. Then it uses this to set the active tab. If the url doesn't include the query string it set the tab to the first one.
The code works but it uses Eval to convert the id string (id[1]) to a variable and I was wondering if there was an alternative.
I am try'g to send window.location.href to the server script who will
generate dynamic javascript according to the referral name comg in as
param:
<script language="javascript" src="NO JAVASCRIPT CAN BE USED HERE" />
So I am see'g If I can use eval todo something what I am doing
I have tried almost everything, following is being last one ....