I am building a short ebook essentially use phonegap.

  • 1
  • Question
  • Updated 5 years ago
  • Answered
How many lines of HTML code is too much for the performance to start slowing down?
Photo of Payam Pakmanesh

Payam Pakmanesh

  • 35 Posts
  • 0 Reply Likes

Posted 5 years ago

  • 1
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
Depends. How long are your lines?

(That was not a serious answer, but I suspect that your question wasn't, either.)
Photo of Payam Pakmanesh

Payam Pakmanesh

  • 35 Posts
  • 0 Reply Likes
Hi Petra,

It's about 2000 lines of code in the html file. When I emulate it on a device and press buttons to go to the next chapter (for example), it feels slow. So I'm wondering if phoneGap is the best solution for something like this.

Thoughts?
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
Do you have one html file with many DIVs for 'pages'?
If so, wouldn't you like to split them up in multiple pages, only including them (using Ajax or a famework like jQM) when needed? That way, the webview doesn't need to build up a large DOM right away.
Photo of Payam Pakmanesh

Payam Pakmanesh

  • 35 Posts
  • 0 Reply Likes
That's correct. I have one html file with many divs for pages.

Can you elaborate what you mean? So you think I should have several html files and when a btn is clicked render a different div/page from a DIFFERENT html file?
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
It would at least be a good option to test and see if it improves anything. The app should display its first page more quickly and be hardly any slower on page transitions.
Do you know or use jQuery Mobile? It supports such architecture excellently and performs the page inclusions and transitions for you.
Photo of Payam Pakmanesh

Payam Pakmanesh

  • 35 Posts
  • 0 Reply Likes
I am using jQuery mobile, I was just under the assumption that I should put all the html content in one file as opposed to let's say 15 files (one per chapter).
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
With jQM, you can create as many html documents as you like. The HEAD section of index.html will be read and parsed....of all other pages, jQM will find the div with role=page and 'activate' that div while 'deactivating' the (only) div of the previous page. jQM will in fact hijack every internal hyperlink and transform it into an ajax request.

As a result, your whole app is set up as a traditional website with html documents for each 'page'.
Photo of Payam Pakmanesh

Payam Pakmanesh

  • 35 Posts
  • 0 Reply Likes
Ok, I see.

So let's say if below is how I reference a different phase(chapter):

'see image'

And when I click the link it will look for the div with id phase1 in the same file. If I move the phase 1div to a separate html file called 'phase1.html' how will I reference it in the link?

Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
You would use href="phase1.html".
See for instance http://thehungrycoder.com/javascript-...
Photo of Payam Pakmanesh

Payam Pakmanesh

  • 35 Posts
  • 0 Reply Likes
Thank you! You have been very helpful. And do you think this will solve the performance issue?

Another question I had was regarding the in app purchases for iOS and Android. I know there is a plugin for iOS, how about Android?
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
And do you think this will solve the performance issue?
Can't tell. You wrote something about "emulator" and "feeling slow". I would guess that things could be different on real life devices without emulator, and also that someone else would not perceive it as slow. Remember that PGB apps run as parsed and interpreted html in webviews, which is always slower than native bytecode in native (list-, grid- and whatnot-) views. Often, PGB apps may not be expected to be lightning fast.
Then there is the amount of data which you read through an online connection, which might slow down page transitions.

If it was me, I wouldn't consider the number of code lines the most important cause for possible slow page transitions. That's why I initially replied a bit ironically. On a perceived slow application, I would first try to find out (benchmarking) where the bottle necks are, and only after finding a root cause, I would start thinking about possible solutions. In such cases it wouldn't make sense deciding on solutions for not yet defined problems.
Photo of Payam Pakmanesh

Payam Pakmanesh

  • 35 Posts
  • 0 Reply Likes
Thanks, Petra. How can I determine what the bottlenecks are in this case? I've read some articles on how to increase the performance in PG apps and followed their steps. However, you could be right and this just may be slow on an emulator. Is there a way for me to test the app on my phone without use phonegap build? I heard that isn't the best solution...

thanks again
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
Well, you could measure actions (like transitions) by using time stamps in your code and subtracting them to find elapsed times.
But in fact, you are more worried about perceived application speed, so your best test would be to install your PGB built apps on various test devices and play around. Have others play around, too, and comment on the app.

I am unsure why you say "without phonegap build", because PGB only builds the app in various ways, so you can download and test the result (.apk, .ipa and .xap files).

BTW: is it really important that the app feels like a fast program? I ask, because you said it was an eBook app. And I wouldn't expect eBook apps to require blazing transition speed. People can wait for half a second longer before they flip the page, right?
Photo of Payam Pakmanesh

Payam Pakmanesh

  • 35 Posts
  • 0 Reply Likes
You make good points! I will follow your advice.

My last challenge is trying to incorporate IAP for both iOS and Android. I've seen some tutorials online but they are all for older versions of Itunes connect. I have 3 in non-consumbable in app purchases I would like to add, but can't find a good tutorial.

Do you know of any?
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
Not from experience, no.
But one of the most used plugins is this one:
http://plugins.cordova.io/#/package/c...

The documentation of the plugin looks promising, the plugin appears to be 'alive' (last update: 2 months ago,version 3.10.1).

Other plugins can be found here:
http://plugins.cordova.io/#/search?se...

If you have any questions about such plugins, you can either ask the author directly (mail address in plugin documentation) ar start a new thread - here or at stackoverflow.
Photo of Payam Pakmanesh

Payam Pakmanesh

  • 35 Posts
  • 0 Reply Likes
Awesome! Thanks again. My main concern with these plugins is, will they just stop working if someone doesn't keep them updated and a new iOS comes out? Will people be charged and then not receive the product? This is where I'm a little confused.

Last question before I take it to a new thread.

thx
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
Your concern is legitimate. Yes, if the plugin stops being available, you are in trouble. If a plugin performs tasks differently from advertised, you're in trouble.

There are just a few alternative options, and they may all be less desirable:
- create and manage your own private plugin
- refrain from offering in-app products (you could sell through a linked website, which is shown in the system browser, away from the app)
- refrain from selling anything (free app, period)
....or use such plugin and hope for the best.

Whichever option you pick, it is definitely a good idea to have a 'termination strategy' for cases where you must suddenly discontinue your app. No app will live forever, so actually every app owner should have an exit strategy prepared.
Photo of Payam Pakmanesh

Payam Pakmanesh

  • 35 Posts
  • 0 Reply Likes
You make great points, however, I thought I can't have a link in the app redirect externally? I remember someone mentioning this to find out how to avoid apple's 30% cut. Because I could just build the app and redirect it to a ebook pdf site and sell the content there.
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
It depends on your products. I was not 100% aware that you were aiming to sell pdf-like content which is going to be used directly within your app.

From Apple:
Apps that link to external mechanisms for purchases or subscriptions to be used in the App, such as a "buy" button that goes to a web site to purchase a digital book, will be rejected

So, if such product cannot be used in your app, it's all OK. If you are selling articles that are directly used within the app, such as eBooks, postcards or additional 'lives' in a game, then yes, you must use IAP and support Apple financially.
Photo of Payam Pakmanesh

Payam Pakmanesh

  • 35 Posts
  • 0 Reply Likes
Well what I mean is, to avoid having the plugin not work properly in the future and risk losing customers. Would it be a better option to just have a link that goes to my site where instead of writing the content within the HTML, I just sell and Ebook with the same content from my site. Avoiding apples 30% cut and avoiding the risk of a plugin not working in the future. Make sense?

Sorry if I was not clear in the last email.
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
You could certainly try that, first. Worst case, the app will be rejected and then you can still decide again on the alternatives.
Photo of Payam Pakmanesh

Payam Pakmanesh

  • 35 Posts
  • 0 Reply Likes
Hi Petra,

Sorry to reply to this thread again, but I posted on another thread and haven't heard from anyone. When I submit my app to PGB and download the ipa file, I sync it with my itunes and put it on mu phone but it gets stuck on the 'Installing..." loop and doesn't finish.

I have the latest version of PG in my file 3.6.3
I also tried recreating the certificates and ID's in apple's developer site

What do I need to do to fix this?

Thanks so much
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
My first guess would be something with the mobileprovision:
- it may be a distribution file, not development
- if development, it may not have your device or the correct AppId included
- it could also be the certificate: is it a wildcard certificate?
Photo of Payam Pakmanesh

Payam Pakmanesh

  • 35 Posts
  • 0 Reply Likes
Well I re-created the mobileprovisioning file. But when I look everywhere online people are saying I need to included my UDID? Where would I do that if that's the case?

I don't think it's a wildcard certificate. I followed a pretty detailed tutorial on how to create all the files. https://www.youtube.com/watch?v=f3Y1a...
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
So, you're not going to develop more than one app for the same package id group (as in: com.mycorp.app1 and com.mycorp.app2)?

For App IDs and Devices, see
https://developer.apple.com/library/i...