You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Anton Vodonosov (Issue Comment Edited) (JIRA)" <ji...@apache.org> on 2011/12/06 15:27:40 UTC

[jira] [Issue Comment Edited] (WICKET-4236) Use JQuery as a backing library for Wicket's JavaScript code

    [ https://issues.apache.org/jira/browse/WICKET-4236?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13163618#comment-13163618 ] 

Anton Vodonosov edited comment on WICKET-4236 at 12/6/11 2:27 PM:
------------------------------------------------------------------

I have a piece of HTML stored in global variable gText.

Here are several functions which replace an element with ID 'id6d' by this HTML 10 times and display the total time.

IE8, jQuery 1.6.1, Wicket 1.4.19.

<code>
// this takes 4 seconds
function test() {    
  var start = new Date().getTime();    
  for (var i = 0; i < 10; i++) {
      Wicket.replaceOuterHtml(document.getElementById('id6d'), gText)
  }
  var end = new Date().getTime();      
  alert('total time: ' + (end - start));  
}

// this takes 10 seconds
function test2() {
  var start = new Date().getTime();    
  for (var i = 0; i < 10; i++) {
	$('#id6d').empty().replaceWith(gText);
  }
  var end = new Date().getTime();      
  alert('total time: ' + (end - start));  
}

// this takes 10 seconds
function test3() {
  var start = new Date().getTime();    
  for (var i = 0; i < 10; i++) {
    var elem = $('#id6d');
    var parent = elem.parent();
    elem.remove();
    parent.append(gText);
  }
  var end = new Date().getTime();      
  alert('total time: ' + (end - start));  
}

// this takes 2 seconds
function test4() {
  var start = new Date().getTime();    
  for (var i = 0; i < 10; i++) {
    var elem = document.getElementById('id6d')
    var parent = elem.parentNode;
    parent.replaceChild($(gText).get(0), elem)
  }
  var end = new Date().getTime();      
  alert('total time: ' + (end - start));  
}
</code>

                
      was (Author: avodonosov):
    I have a piece of HTML stored in global variable gText.

Here are several functions which replace an element with ID 'id6d' by this HTML 10 times and display the total time.

IE8, jQuery 1.6.1, Wicket 1.4.19.

<pre><code>
// this takes 4 seconds
function test() {    
  var start = new Date().getTime();    
  for (var i = 0; i < 10; i++) {
      Wicket.replaceOuterHtml(document.getElementById('id6d'), gText)
  }
  var end = new Date().getTime();      
  alert('total time: ' + (end - start));  
}

// this takes 10 seconds
function test2() {
  var start = new Date().getTime();    
  for (var i = 0; i < 10; i++) {
	$('#id6d').empty().replaceWith(gText);
  }
  var end = new Date().getTime();      
  alert('total time: ' + (end - start));  
}

// this takes 10 seconds
function test3() {
  var start = new Date().getTime();    
  for (var i = 0; i < 10; i++) {
    var elem = $('#id6d');
    var parent = elem.parent();
    elem.remove();
    parent.append(gText);
  }
  var end = new Date().getTime();      
  alert('total time: ' + (end - start));  
}

// this takes 2 seconds
function test4() {
  var start = new Date().getTime();    
  for (var i = 0; i < 10; i++) {
    var elem = document.getElementById('id6d')
    var parent = elem.parentNode;
    parent.replaceChild($(gText).get(0), elem)
  }
  var end = new Date().getTime();      
  alert('total time: ' + (end - start));  
}
</code></pre>

                  
> Use JQuery as a backing library for Wicket's JavaScript code
> ------------------------------------------------------------
>
>                 Key: WICKET-4236
>                 URL: https://issues.apache.org/jira/browse/WICKET-4236
>             Project: Wicket
>          Issue Type: Sub-task
>          Components: wicket, wicket-extensions
>    Affects Versions: 6.0.0
>            Reporter: Martin Grigorov
>            Assignee: Martin Grigorov
>             Fix For: 6.0.0
>
>
> wicket-ajax.js has accumulated a lot of custom written code to be able to serve the needs of Wicket Ajax behaviors and components.
> This custom javascript code can be greatly simplified by using any bigger JavaScript library that is specialized in handling browser differences. 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira