4

I am developing an Android app in Phonegap. I have 3 page , by using "Button click" the page is going to another page. My issues is when I click the button response is very slow, it took 1 to 2 sec to go to the next page.

Here am using div transition to show each page "homePage" and "imgSelectPage" are class name for div.

 $('.play a').click( function(e){
    e.preventDefault();
    $('.homePage').hide();
    $('.imgSelectPage').show();
});

Is there any method to improve the speed to change one page to another page by clicking the button

Thanks in advance

  • Replace 2 jQuery lines with alert("test"); You need to check if jQuery hide() / show() takes long time in this case. –  Jul 01 '15 at 06:39
  • @xiaowu am using div transition to show each page "homePage" and "imgSelectPage" are class name for div.is there any other method other than using jQuery –  Jul 01 '15 at 06:41
  • Do you use FastClick for mobile app. In mobile, event click will be wait 300ms to fire. – Hanh Le Jul 01 '15 at 08:36
  • @ Hanh Le yes , i used fastclick, but no improvement –  Jul 02 '15 at 04:02

1 Answers1

0

If you use the selectors more then once you could set a variable. This is more effective because jQuery only searches the element once.

And use the minified version of jquery and not a debug version.

If this did not help you should inspect how the methods .hide() and .show() behave just like @xiaowu said

Lioman
  • 511
  • 8
  • 18
  • yes am using minified version of jquery . As xiaowu said am agree with his point , because of jQuery it look like slow tarncition. But is there any other method for transition of div class other than using jQuery –  Jul 01 '15 at 06:57
  • Yes, you can use angularJS. And if you want to build an application in material design I recommend [AngularMaterial](https://material.angularjs.org/latest/#/). We developed a cordova application quiet fast with the help of these libraries. – Lioman Jul 01 '15 at 07:04