How to speed up slow javascript?

Hi,

For some reason my javascript file gets very slow when it reaches a size hardly exceeding a couple of pages.
Not just code asist, but even typing code itself lags. It is frustrating enough to spend time on, and so here's why I didn't file it as an issue:

I know you were aware of some speed issues in the eap's so you must be working on it already. I was thinking since I have generally little to no regard about conforming to coding standards and existing architectures could the highly dynamic nature of the language be setting up a bottleneck at some of my more experimental constructs?

Would someone have some ideas as to what kind of javascript code generally could have an effect of slowing down the phpstorm system?

Thanks for your input!

1
9 comments
Avatar
Permanently deleted user

Hello Leo,

Can you please provide some of your files (it can be done privately by e-mail), or take a performance snapshot according to http://devnet.jetbrains.net/message/5290216#5290216?

Thanks,
Kirill

0

Edit: I would really like, though, to be more informed about the underlaying concepts of the ide and if it's optimized for certain constructs or if some are too heavy for it. The speed problem page lists only the basic and obvious that has nothing to do with the way code is shaped.


This is an excerpt from a php file I've been working on for a very simple discussion.
It's contained within a script tag at the bottom of a mix of php and html.
It uses jQuery 1.5 and
A javascript file (15 pages or so) that keeps a number of functions I've written - so all the functions that are not part of jquery are contained there.
Generally I would much rather work in my large javascript file, but it is impossibly slow at this point, so I work directly in the php and later copy it over, but even this is slowing down.

My system: Snow Leopard .6.6 Macbook Pro core 2 duo 2.4Ghz 4G ram:

<script type="text/javascript">                var reply_area = '.reply textarea';                                var myname = "<?php echo ucwords($user['first_name'] . ' ' . $user['last_name']); ?>";                var myavtr = "<?php echo user_avatar($user) ?>";                var myurl = "<?php echo root().'/profile/'.$model->build_user_url_key($user) ?>";                var activate_discussion_reply = function(selector,myname,myavtr,myurl)                {                     $(selector).live('keydown', function(e)                     {                          if (e.keyCode == 13)                          {                               var $t = $(this);                               var dis_id = $t.attr('id').replace('reply_discussion_id_', '');                               var body = $t.val();                               $t.val('').blur();                               post_comment(dis_id,body,function(success,data){                                    if(success){                                         $t.parent().before(compose_comment(data.id,myname,myavtr,myurl,body,'just now'));                                    }                                    else{                                         if (data){                                              $.each(data.errors, function(){                                                   $t.before('<p >' + this + '</p>');                                              });                                         }                                    }                               });                          }                     });                };                var post_comment = function(target_id,body,callback)                {                     $.post('query.php?operator=discussions', {                          operation:'post_comment'                          ,target_id:target_id                          ,body:body                     },                     function(data)                     {                          if (data.errors)                          {                               if (count(data.errors) > 0)                               {                                    if (callback)callback(false,data);                               }                               else                               {                                    if (callback)callback(true,data);                               }                          }                          else                          {                               console.log(data);                               if(callback)callback(false);                          }                     }, 'json').fail(function(data)                     {                          console.log(data.responseText);                          if(callback)callback(false);                     });                };                var compose_post = function (item_type,id,name,avtr,url,body,time_str,can_remove,can_flag)                {                                          };                var compose_comment = function (id,name,avtr,url,body,time_str,can_remove,can_flag)                {                     can_remove = can_remove || true;                     can_flag = can_flag || false;                     var html =                          '<div id="discussion_post_id_' + id + '">'                               + '<span ></span>'                               + '<span >'                                    +'<img alt="' + name + '" src="' + avtr + '">'                               + '</span>'                               + '<span >'                                    + '<span >'                                         + '<a href="' + url + '" >' + name + '</a> '                                         + safe_encode(body)                                    + '</span>'                                    + '<div >'                                         + ' <span >'                                              + time_str                                         + '</span>'                                         + (can_remove ? ' <a href="">remove</a>' : '')                                         + (can_flag ? ' <a href="" >flag</a>' : '')                                    + '</div>'                                    + "<span class='end'></span>"                               + '</span>'                          + "</div>";                     return html;                };                var compose_topic = function (topic_id,abcdef)                {                };                var post_new_topic = new function (target,target_id,body)                {                                     };                ta_auto_grow(reply_area);                input_placeholder(reply_area,'Press enter when finished.');                         activate_discussion_reply(reply_area,myname,myavtr,myurl);

0

Incomplete code is almost useless, sorry.
Please get latest EAP build (PhpStorm 2.1#444), collect more information about the problem per instructions in http://devnet.jetbrains.com/docs/DOC-192 and attach it to the YouTrack ticket.

0

Thanks, but I believe my request was a bit more sublime than "fix my slow ide".
I din't see any answers to my question on your site or in help.

An example of an answer could be "phpstorm currently does not handle nested inline variable functions very well" or "phpstorm will parse faster if variables are defined first in an object". This is an approach from the opposite side of the issue where instead of you analyzing my code you would tell me more about your system's parsing philosophy.

Cheers

0

Well, we need the requested CPU snapshot to give you any advice or fix our IDE.

0

Thanks for your attention, but I still feel like my question is not being understood.
You see if I give you a snapshot - this will make the request specific to me and my project.
I wanted to know if there was an ide-specific direction or preference. So to speak, the subject of my sentence isn't myself but the ide.

Is the question un-answerable? Is it a trade secret? Or is it simply boring to everyone at Intellij to talk about the underlaying principles of their software?

Kind regards

0

Well, the general idea is that code should target developer and not the IDE.
IDE should ideally understand any code.
Anyway - the logic behind JS code analysis is way to complex to explain.

Also, I think we are kind of focused on practical side - if there obvious performance problems in IDE that you were able to reproduce we want to fix them. And to check that we need either full source code or at least proper performance snapshot.

0
Avatar
Permanently deleted user

I have same issue for WebStorm 8.  I am looking for solution/answer here around.  But it is interesting to find out that in this forum it seems always advise for uploading CPU snapshot since 2010 or earlier post.  Could not find a solution till today, May, 2014.

How long it would take for JetBrain guys to spend (so many years) and still doing analysis and still no clue?

-1
Avatar
Liubov Melnikova

The root cause of the issue can be different from 2010 to 2014. If you experience performance issue, take care to follow: https://intellij-support.jetbrains.com/entries/29983118 and feel free to file a bug report: http://youtrack.jetbrains.com/issues/WI#newissue=yes .

0

Please sign in to leave a comment.