You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wicket.apache.org by GitBox <gi...@apache.org> on 2019/08/28 00:10:50 UTC

[GitHub] [wicket] andruhon edited a comment on issue #378: WICKET-6688 add RFC support (to avoid unsafe eval)

andruhon edited a comment on issue #378: WICKET-6688 add RFC support (to avoid unsafe eval)
URL: https://github.com/apache/wicket/pull/378#issuecomment-525530622
 
 
   > It's not clear who will clean-up all those header items. 
   
   The header item wipes itself on the last line https://github.com/apache/wicket/pull/378/files#diff-a7f583254a200944d085608b18d15244R2153
   
   > Can we garantee, thas this doesn't impact the browser performance (e.g. garbage collection)?
   > _If_ this solution works, why bother with this RFC at all, and just use header items all the time?
   
   The approach with header items is not particularly slow, however it's aimed to HEADER ITEMS. The direct call to predefined code is about 10 times faster than adding a new node in chrome. Please have a look at the exercise below:
   
   ```
       window.myNameSpace = {};
       window.myNameSpace.doSomething = function (){
         document.getElementById("myTestContainer").innerHTML = Date.now();
       };
   
       var cycles = 10000;
       var withDomStart = Date.now();
       for(var i = 0; i < cycles; i++) {
         var myScript = document.createElement("script");
         myScript.id = "myScr"+i;
         myScript.innerHTML = 'window.myNameSpace.doSomething(); document.getElementById("'+myScript.id+'").remove();';
         myScript.nonce = "4AEemGb0xJptoIGFP3Nd";
         document.head.appendChild(myScript);
       }
       var withDomTime = Date.now() - withDomStart;
       console.log("Execute with dom total, ms", withDomTime);
       console.log("Execute with dom average, ms", withDomTime/cycles);
   
       var withoutDomStart = Date.now();
       for(var i = 0; i < cycles; i++) {
         window.myNameSpace.doSomething();
       }
       var withoutDomTime = Date.now() - withoutDomStart;
       console.log("Execute without dom total, ms", withoutDomTime);
       console.log("Execute without dom average, ms", withoutDomTime/cycles);
   ```
   The output is:
   ```
   Execute with dom total, ms 786
   Execute with dom average, ms 0.0786
   Execute without dom total, ms 87
   Execute without dom average, ms 0.0087
   ```
   
   The difference is a way smaller if the function also creates and removes nodes, which usually happens when we add a new element onto the page. However, there must be a tidy way to call the function without touching the DOM at all (rfc/rpc).
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services