Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2011-02-12
16
Medium Priority
?
896 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 3
  • 2
  • +1
16 Comments
 

Author Comment

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

Expert Comment

by:Rob
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
Major Serverless Shift

Comparison of major players like AWS, Microsoft Azure, IBM Bluemix, and Google Cloud Platform

 
LVL 43

Expert Comment

by:Rob
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
 
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

Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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.

705 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