Solved

Jquery  google translate throws "A script on this page is causing Internet Explorer to run slow"

Posted on 2011-02-12
16
864 Views
Last Modified: 2013-11-11
On a large page with many elements      running the attatched code in IE8 results in the message "A script on this page is causing Internet Explorer to run slow" that prompts to stop or continue the script.

1.tried     async:true but did nothing
<script type="text/javascript" >



             jQuery.noConflict();

             jQuery(document).ready(function () {
                 jQuery(function (jQuery) {


                     var jQuerydestLang;
                     var jQuerydestLang = null;
                     jQuery.translate(function () {
                         jQuery.fn.translateTo = function (destLang) { jQuery('#translateit').translate('english', destLang, {  not: ' #ctl00_Menu1_ctl06_HyperLink2,#ctl00_fname,#ctl00_ftel,#ctl00_femail,#fmessage  ' }); return true; };








                         jQuerydestLang = '<asp:Literal ID="Literal1" runat="server">null</asp:Literal>';

                         if (jQuerydestLang) { jQuery.fn.translateTo(jQuerydestLang};


                     });

                 })
             })

Open in new window

0
Comment
Question by:rodojohn
  • 8
  • 3
  • 2
  • +1
16 Comments
 

Author Comment

by:rodojohn
ID: 34879092
the webpage is in asp.net (c#)
0
 
LVL 42

Expert Comment

by:Rob Jurd, EE MVE
ID: 34894377
For what reason have you nested the JQuery functions?

eg.

jQuery(document).ready(function() {
    jQuery(function (jQuery) {
...
0
 

Author Comment

by:rodojohn
ID: 34896270
its my first use of jquery & its implementation and i followd the wiki documentation http://code.google.com/p/jquery-translate/wiki/General , every exampe is nested and i dont know why exactly , but i followed their practise.
0
 
LVL 42

Expert Comment

by:Rob Jurd, EE MVE
ID: 34900543
Are you using noConflict because you ate using another framework or again because of their practice?
0
 

Author Comment

by:rodojohn
ID: 34900644
i had troubles with the $ syntax wich was ambiguus in my page which i also use the Ajax .net control again having a $ , i was getting e.g .translate not a function although the translate script was loaded, so finally i deprecated for this site the $ with ading the NoConflict.
0
 
LVL 27

Expert Comment

by:BigRat
ID: 34928230
What does this do :-

 jQuerydestLang = '<asp:Literal ID="Literal1" runat="server">null</asp:Literal>';


Is this page causing many call backs to the server?
0
 

Author Comment

by:rodojohn
ID: 34928304
this line sets the selected language serverside and is to keep the language alive through the site

literal generates no code and i set the inside e.g. fr

which becomes jQuerydestLang = 'fr';

it works fine
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 27

Expert Comment

by:BigRat
ID: 34928462
OK, fair enough. The problem is that Script runs on eth browsers GUI thread and when it spends too much time another thread suspends operation and produces the message box. Is it absolutely necessary to use the functions as such, since each instatiation causes an execution context to be created and destroyed? That is can't the functions simple be static and passed as reference instead of as text?

[When you write x = function() {.......}; x gets set to the text of the function. When one does x(...) the interpreter calls the parser, parses the script, creates the execution context and executes the function. When you write function abc(...) {...}    x=abc; then the function pointer is passed, there is no parsing and no execution context needs to be created]
0
 

Author Comment

by:rodojohn
ID: 34928484
also it causes no call back to my server
0
 
LVL 27

Expert Comment

by:BigRat
ID: 34928504
That I understood. Sorry but it is almost 20:00 and it's cheese time. Back Monday.
0
 
LVL 16

Expert Comment

by:BurnieP
ID: 34930529
Hi,

I saw two things, maybe it is the cause of your problem or maybe not.

First,  on line 25 of your first post :

if (jQuerydestLang) { jQuery.fn.translateTo(jQuerydestLang};

You are missing a ')'. it should be :
if (jQuerydestLang) { jQuery.fn.translateTo(jQuerydestLang)};

Next, the way I read your code, you are doing document.ready twice.

You start with these two lines :

jQuery(document).ready(function () {
                 jQuery(function (jQuery) {

Which to me is the same thing but written differently.  I have simplified your function in the code below.  Worth a shot trying.


<script type="text/javascript" >
  jQuery.noConflict();
  jQuery(document).ready(function () {
    var jQuerydestLang = null;

    jQuery.translate(function () {
      jQuery.fn.translateTo = function (destLang) { jQuery('#translateit').translate('english', destLang, { not: ' #ctl00_Menu1_ctl06_HyperLink2,#ctl00_fname,#ctl00_ftel,#ctl00_femail,#fmessage  ' }); return true; };
      jQuerydestLang = '<asp:Literal ID="Literal1" runat="server">null</asp:Literal>';

      if (jQuerydestLang) { jQuery.fn.translateTo(jQuerydestLang) };
    });
  });
</script>

Open in new window

0
 

Author Comment

by:rodojohn
ID: 34950299
BurnieP very Good  Proposal but unfortunatelly it didnt solve the IE problem :(
0
 

Accepted Solution

by:
rodojohn earned 0 total points
ID: 34953237
On some pages that can happen, just use the async:true option! It will take more time but won't freeze the browser. You can probably set it to false on other browsers if they don't complain about this. Also, you can try the jQuery('#translateit').translateTextNodes() method instead of jQuery('#translateit').translate().
Delete comment
Comment 3 by rodoj...@gmail.com, Today (moments ago)
async:true; didnt worked but translateTextNodes() worked fine, no slow script message now

http://code.google.com/p/jquery-translate/issues/detail?id=63
0
 

Author Closing Comment

by:rodojohn
ID: 34990843
help from the official jquery & googgle api reference
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

In this article you'll learn how to use Ajax calls within your CodeIgniter application. To explain this, I'll illustrate how to implement a simple contact form to allow visitors to send you an email through your web site.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now