tsi / inlineDisqussions

Inline comments for your site.
http://tsi.github.io/inlineDisqussions
MIT License
183 stars 29 forks source link

Performance problem - Stress Testing #6

Open titombo opened 10 years ago

titombo commented 10 years ago

I used your method for 3004 paragraphs in a text, check the javaScript bellow:

<script>

  disqus_shortname = 'myShortNameDisqus';
  jQuery(document).ready(function () {

     // jQuery("p"); returns 3004 elements
      jQuery("p").inlineDisqussions(
          {
              position: 'right',
              displayCount: false
          }
          );
  });
</script>

http://cfcomentada.azurewebsites.net/ It took 25 seconds to execute. Is there a way to make the execution quicker ? Since this page is not gonna change, maybe there is a way to store the per-proccessing somewhere.

Is this generated each time it runs the script ? http://cfcomentada.azurewebsites.net/js?v=rHWjXiMtWOTPjhUf3vKK52W1uMgkpJt0Wyh5RANE5MQ1

Thanks for the API, is helping a lot. :+1: :)

tsi commented 10 years ago

The only thing that can cause such execution time is the script that fetches the comments count from Disqus to display them besides the paragraphs (the actual comment threads are not being pre-fetched). You can prevent this script from running by passing displayCount: false in your settings object. you won't be able to display the comment count though.

titombo commented 10 years ago

But already is set to '''displayCount: false''', check the code I just sent on the comment before.

Probably is one of these document.createElement. It generates this kind of script, and there is a repetition, maybe it can concatenate, here is an example of script that is gereated:

http://cfcomentada.azurewebsites.net/js?v=rHWjXiMtWOTPjhUf3vKK52W1uMgkpJt0Wyh5RANE5MQ1/event/seq/1/anonymous

function (n){return typeof i===o||n&&i.event.triggered===n.type?t:i.event.dispatch.apply(l.elem,arguments)} function (n,i,u){return null==n||"boolean"==typeof n?r.apply(this,arguments):this.animate(vt(t,!0),n,i,u)} function (n,i,u){return null==n||"boolean"==typeof n?r.apply(this,arguments):this.animate(vt(t,!0),n,i,u)} function (n){return typeof i===o||n&&i.event.triggered===n.type?t:i.event.dispatch.apply(l.elem,arguments)} function (n){return typeof i===o||n&&i.event.triggered===n.type?t:i.event.dispatch.apply(l.elem,arguments)} function (n){return typeof i===o||n&&i.event.triggered===n.type?t:i.event.dispatch.apply(l.elem,arguments)} function (n){return typeof i===o||n&&i.event.triggered===n.type?t:i.event.dispatch.apply(l.elem,arguments)} function (n){return typeof i===o||n&&i.event.triggered===n.type?t:i.event.dispatch.apply(l.elem,arguments)} function (n){return typeof i===o||n&&i.event.triggered===n.type?t:i.event.dispatch.apply(l.elem,arguments)} function (n){return typeof i===o||n&&i.event.triggered===n.type?t:i.event.dispatch.apply(l.elem,arguments)} function (n){return typeof i===o||n&&i.event.triggered===n.type?t:i.event.dispatch.apply(l.elem,arguments)} function (n){return typeof i===o||n&&i.event.triggered===n.type?t:i.event.dispatch.apply(l.elem,arguments)}

It seems that create.Element is better even than an equivalent jQuery method. http://stackoverflow.com/questions/268490/jquery-document-createelement-equivalent

titombo commented 10 years ago

Is there a way to reuse the javaScript code that was already generated, without needing to generate it again ? Maybe a new parameter on the constructor.