JQuery :: Performance For Different DOM Node Creation Methods?
Dec 3, 2010
Does anyone know if there is a significant performance difference between the below two methods of DOM creation in jQuery?
Method 1:
$("<div id='myId' class='one two three' style='width:100px; height:100px; z-index:1;' />").appendTo("body");
Method 2:
$("<div />").attr("id", "myId").addClass("one two three").width(100).height(100).css("z-index", 1).appendTo("body");
I imagine that when using the first method, jQuery does some string processing and eventually ends up doing the same thing as method #2. Is that correct? If so is there a significant performance cost for this? Overall I think the first method is better as far as readability goes but it would be good to also know its effect on performance.
View 2 Replies
ADVERTISEMENT
Dec 7, 2011
I have a small question. I am building an AJAX-based content editor and in one portion the following xml tag needs to be processed:<
[Code]...
View 1 Replies
View Related
Nov 23, 2009
I'm using jsTree-0.9.9a. As a test this is the code i'm using to display the ID
oncreate: function(NODE, REF_NODE, TYPE, TREE_OBJ, RB)
{
if (TYPE === "inside") {
parent_id = $(REF_NODE).attr('id');
alert(parent_id)
}}
This works fine when the parent has no child nodes, however, when a child node exists nothing is returned.
View 1 Replies
View Related
May 27, 2010
I need to move the entire contents of one div to a sibling div. At present I'm just doing (assuming the 2 divs are called 1st and 2nd):
What I need to know is if this is the quickest means (in performance terms) of doing this as I will be performing the operation regularly and on a large number of nodes and it's in an area where the UX really can't stutter ?
View 4 Replies
View Related
Sep 23, 2009
Does Jquery perform better or worse than other Java library with regard to not triggering pop up blockers?
View 2 Replies
View Related
Jul 2, 2009
I just tested all my jQuery selectors using the jQuery Tester [url], and the results seem to "contradict" one thing I read in a performance article: that you should descend from the closest parent ID when using classes in your selector (the article says "April 09", so the latest jQuery version was already available). In my tests, using just the class selector (like span.myClass) was always fastest (sometimes twice as fast as #myDiv span.myClass), and this in all browsers I tested, not just the ones supporting getElementsByClassName. Maybe descending from the closest parent ID becomes a factor when you have a lot of elements on you page?
View 6 Replies
View Related
Jul 30, 2010
[URL]...why this is getting amazingly slow after running some while?
View 1 Replies
View Related
Apr 2, 2010
I pull XML from server using .load() and then iterate with .each() over some 3000 nodes. I use .find() to get 7 sub-nodes and store them internally (into arrays). It works, but it is disappointingly slow. On my obsolete P4 it can take 8-10 seconds during which the whole browser (FF) is completely frozen. On faster computers the processing time is shorter, but still way too long. What can I do to cut this time? I certainly need speed up of an order, two orders would be nice. Would JSON be any faster? Or should I pull text/plain in custom format and parse it in my JS code?
View 5 Replies
View Related
Apr 7, 2010
I have a php search page with can potentially display several hundred records. For each record, there is an icon which, when clicked, makes an ajax call. When the reply comes back, the text returned from the server script is added to a specific div and the source of the icon that the user clicked is changed (as a visual cue that that particular item was selected).
This works 100% perfect in FireFox (3.5.9), Chrome, and IE 7. However when I test it in IE 8 there is a HUGE lag between when the icon is clicked and when the div and icon are updated (usually between 10-15 seconds). By commenting out one line at a time, I've narrowed it down to the line that changes the src attribute of the icon...if I just comment that line out, the ajax call is made and the div is updated instantaneously.
[Code]...
View 5 Replies
View Related
May 11, 2010
On our website we wanna bind a click (or maybe mouseover)-event on every user-image. The click on the image should open a layer with further information about the user. Now i look for a best practice way to solve this (focus on performance), because there could be a lot of user-images on one side. I think, if i bind the event on a class like this
jQuery('.myclass').bind('click', function(
makerequest;
openlayer;
))
that could slow down the site, because i read, that "The class selector is the slowest selector in jQuery". Back to the roots and insert an onclick(function) to the element, but i'm not realy happy with that solution.
View 1 Replies
View Related
Apr 23, 2010
I'm trying to build a page that has multiple ajax calls on it. When you do it the old-fashioned way with XmlHttpRequest, you'd create a new xhr object for every call so that they execute simultaneously. If I try to do this in jquery it will only execute a call when the previous one has completed. This makes the page load time completely unacceptable. How to improve the performance?
View 2 Replies
View Related
May 3, 2011
i working on web map of MMORPG gamehttp:[url].....(here is "working" version dont comment a code, its shitty i working on funkcionality,i will perform code cleaning and optimalizacion after i implement all needed functions and solve all my problems)so i have 2 problems:
1) map performance when zooming.i need drawn ~600 dots of NPCs on map and recalculate their positions on map when zoom in/out, my current solution is slow ( cleaning and appending HTML into map content) i wana know if there is faster solution how do it ?
2)i using jQuery tooltips to show data when NPC or fort icon is mouseovered , it works great only with one problem, when i zoom with tooltip opened , it loose "connecion" with fort/NPC icon and tooltip stuck on screen...
View 3 Replies
View Related
Jan 10, 2012
I just wonder if there is a jquery plugin or something that enable me to create a html pagelayout with drag n drop.
Lets say i have a blank page with a div container, then i have a couple of layout elements that i can drag into that container, like 2 coulmn, 1 column, 3 column.
I hope you understund what i mean. something like sitefinitys template builder but in a light version.[URL]
View 1 Replies
View Related
Jul 18, 2011
I am running a program that makes > 50,000 ajax calls. Each time an ajax call is made a temporary function is created (by jQuery, not by me):
jQuery1620667739100754261_1311033524438
:function (a){g=[a]}
arguments
:null
[Code].....
So I end up with tens of thousands of these undefined global variables. I believe this is cause my script to fail and I am wondering if there is an easy way to fix this short of either editing the jquery library to delete these (can this be done?) orwritingmy own ajax function.... All other variables are getting smaller at the point of failure which isconsistentregardless of other changes made to the program.
I am testing on google chrome, but would like it to remain able to be used across updated browsers.
View 1 Replies
View Related
May 28, 2010
Can someone tell me why this snippet of code does not work in any version of IE yet works fine in Firefox and Chrome?
<?
require_once("db/db.class.php");
$db = new db_class;
$classId = intval($_GET['classId']);
$selSub = intval($_GET['selsubclassId']);
$d = $db->connect();
[Code]...
It should be creating a set of options for a the select statement with id "sub_class", which it does.However, it should also be setting the selected option to the value I pass as 'selsubclassId', which only seems to work in FF or Chrome. In IE, the selected item always defaults to the first option.It's pretty basic PHP and jQuery. Is IE that stupid? Do we have a workaround?
View 1 Replies
View Related
May 28, 2010
I have a function where I want to add a sibling element to each of the elements and trigger a click on each of them right away. Here's what I have so far:
$(function(){
$('#articles').delegate('.click-link','click',function(){
$(this).toggle(
function(){
alert('toggle one');
},
function(){
alert('toggle two');
});
});
$('.toggle').each(function(){
$(this).after('<span class="click-link">Hide</span>');
$(this).next().trigger('click');
});
});
For some reason the toggle doesn't get triggered. If I put something in the function right before the toggle, it fires on page ready. However, the toggle doesn't fire. toggleClass does, though. What can be causing this?
View 4 Replies
View Related
Jul 20, 2010
I'm dynamically creating a table. I create the <tr>s with five <td>s. I then remove the third <td> and would like to add the cell variable where I removed the td. The creation of the table works, the removal of the td works, now how do I add the cell var where I removed the td? Example here: [URL]
Code JavaScript:
function CreateTable() {
var array = ["one", "two", "three", "four", "five", "six", "seven", "eight", "one", "one", "three", "seven"];
var listItems = "";
var tbody = $('.tbody');
var cell = $('<td>', {
className: 'open',
html: 'Open'
});
$.each(array, function(index, val) {
var row = jQuery('<tr></tr>')
.append('<td>' + index + ' - ' + val + '</td><td> open </td><td> open </td><td> open </td><td> open </td>');
$('td:eq(2)', row).css('background-color', '#eee');
$('td:eq(2)', row).remove();
row = row.add(cell);
row.appendTo(tbody);
});
}
View 2 Replies
View Related
Sep 9, 2009
I would like to add a "Create new..." item to my autocomplete lists togive users a way to create new items. This item would stick at eitherthe top of the bottom of the suggestion list and, when selected, firea callback where I could display a dialog to collect the formationfor the new entry, which would then go into the autocomplete list.I could easily be missing something but this doesn't look possible outof the box.More explanation: I'm selecting from a list of people. If the personI'm looking for isn't in the list I need to pop up a dialog so I canenter their name, email, etc. That new person then gets put into theautocomplete list and selected into the form field.I've been poking around the source code but haven't been able tofigure out a way to implement this yet
View 1 Replies
View Related
Sep 20, 2011
I'm guessing you know this only too well, but here's a reminder: I wanted to leave a comment about errors in the tutorial on the web site (and I will, in my next post) but the mediawiki Login screen, though titled "Log in / Create account", doesn't appear to allow one to create a (mediawiki) account.
View 2 Replies
View Related
Dec 8, 2010
Dynamically creating and assigning elements to a dialog, but I am unable to modify the elements after the window opens. I know that I can see them and they are being correctly assigned because I can look at them with firebug.I was thinking that one source of the problem may be the badly formed html that I am getting out. shouldn't each input tag end with " />"?
$elem = $('<input type="hidden" />').attr('id', elemID).attr('name', elemName).attr("class", elemClass);
if(objectArray[x].f_value && objectArray[x].f_value !== null) {
[code]....
View 1 Replies
View Related
Jul 14, 2010
I have some code which creates an extremely long table row, and I've been able to clean it up to a point where my performance is fairly decent. What I am trying to figure out is if its better in terms of speed to use divs as opposed to the really long table row. I didn't really find much on this topic online, so thought I'd ask out here.
View 2 Replies
View Related
Jan 31, 2010
About when to use setter methods. For example, I have this code
Should this be used like this:
I think a better question is when to use the .each loop? Since, the first line of code I have works fine.
View 1 Replies
View Related
Apr 26, 2007
I have read many of the copius entries on the subject of IE performance (or
the lack thereof) when populating Select Lists.
I don't mind the insert performance so much, (I get 100x120byte rows
inserted/sec up to 500, and 100rows/6secs up to 3000, which isn't great but
then the Row Count is clicking away for the user to see and they can hit the
"cancel" button at anytime, so overall I'm happy), what really disappoints
me is the woeful of .REMOVE()!
Before fetching the next result-set I clear down the existing options (I
*do* have to do this don't I?) by looping through option collection calling
remove(1). (Would it be quicker if I removed the last option? Option[0] is a
header.) For 3000 rows this takes an unbelievable 20+secs :-( Does this
sound about right?
1) Is it only IE that performs badly on this?
2) Is there a quicker or more efficient way of zeroing the Select List?
2a) The w3schools ref says the "length" attribute "Returns the number of
options in a dropdown list" it doesn't say "sets Or returns"
2b) The French guy (Stephane?) suggested that I should just set the length
to zero, but wouldn't that result in a memory leak?
3) Do I need to create a malloc/realloc function that keeps a high-water
mark of available option objects for this Drop Down and only "new" some more
options when that's exceeded? (But then the Length would always be off)
4) Use tables and not select lists?
5) Use another browser
View 11 Replies
View Related
Apr 10, 2009
How to improve the web site loading performance. My current site takes average time 18 sec. to load in first time. and 2nd time refresh it takes 12 sec. through YSlow I am observing the request time it more. how to achieve the better performance. My html code is very much clean and w3c validated.
View 1 Replies
View Related
Nov 18, 2003
I've been working on a redesign of our site at ExperiencePlus for some time now, and long ago chose CBE menu 9 over the other menu technologies out there because of its browser independance. Problem is, as you can see, we have a pretty large site; load-times for the menus and associated scripts are approaching prohibitive. So I'm trying to speed things up.
You can see the results of some simplification here - still about the same speed by my guesstimates.
So, my question is twofold, I guess. First, Mike, do you have any ideas about how long it will take X menu 4 to reach maturity? No pressure ;^) If it were ready now, I'd just drop CBE in favor of X.
Second question: How much performance improvement can I expect from removing unnecessary code (sliding, for example) from the CBE core files? I haven't played with that stuff at all, except to read it now & then when looking for solutions to problems. Does anyone have a similarly large implementation of CBE menu9 that runs faster, so that perhaps they could share their experience?
One final thing: I'm planning to eventually shove all this into a PHP document that will auto-generate chunks of the menu from database queries, especially around the tour & country listings and our "Resource Room." (X menu 4 looks like it would be vastly superior for that purpose, since it's so lean.) I'm interested in hearing from anybody who's tried to do something like this, whether they succeeded or not.
View 6 Replies
View Related
Apr 16, 2004
I have client that has 5 versions of the same site located in web viewable root folders on his server. Aside from a few minor differences such as prices, download url's and a few text and image differences, they're the same.
Just wanted to get some opinion as to how many javascript includes I can, or should, use on the site pages or if there are any strong opinions on not doing it this way.
I'd like to place a set of javascipt files in a folder within each site, then have all pages in each site call to their specific include folder. This way I'll be able to use a single set of DW templates to manage the content on all the sites.
I can't convert to php, use ssi nor create a dynamic solution since the sites are already live and rank well in the search engines, The content I'll be wrapping in the includes is not important search engine text content.
View 1 Replies
View Related