Improve load time for application

Ask questions and share your skills here

Improve load time for application

Postby bsoft » Tue Jan 26, 2010 4:22 pm

Hello all,

just a topic to share experience between nimblekit's users on how you manage to improve your application speed?

Because, my bigger concern is about the load time of application.

Did someone already tried to disabled useless functions in Nimblekit ? (i mean, functions that are not required by your application..)

Sunny, any ideas or tips ?
bsoft
 
Posts: 97
Joined: Mon Jun 29, 2009 9:54 am

Re: Improve load time for application

Postby sunny » Tue Jan 26, 2010 4:35 pm

there are ways.. but all of them have some disadvantages.
For example, NimbleKit waits until the main page is fully loaded before showing it, it can e disabled, application will be shown fast, but as white screen, where the user will see loading.
As for turning off NK features it won't help, 99% times takes HTML file loading, so even if you turn off everything you'll still have application loading time same. Of course we think about different ways and will push hard on this on 1.7 release where we plan to have noticeable performance boost, at the moment I'm not sure how it's possible, but there always have to be ways.
User avatar
sunny
Staff
 
Posts: 1692
Joined: Sat May 30, 2009 5:18 am
Location: kiev, Ukraine

Re: Improve load time for application

Postby bsoft » Tue Jan 26, 2010 4:48 pm

Thx for your answer Sunny.
i know it's difficult.
More over, some framework like jquery doesn't help.. ;)
But even if there is no framework, no JS.. just a white page... html is still very long to load...

Hope you will find a good solution for v1.7.
Do you have any idea of date for this futur release ?
bsoft
 
Posts: 97
Joined: Mon Jun 29, 2009 9:54 am

Re: Improve load time for application

Postby cutmaster » Wed Jan 27, 2010 11:27 am

Regarding improvements, there's several ways to do/help in your application.

First of all, maybe you can add a box on the Default.png image saying the application is loading (it helps the user being more patient).

Second, personaly I've managed to completly remove jQuery and rewrite quickly only needed functions (such as Dom access (without unusefull functions), fade in/out, etc. and I've noticed a REAL speed improvement while changing pages (this is more noticable on an iPhone 3G instead of a 3GS).

Also, adding some functionnalities using Cocoa mix instead of making it fully in javascript helps a little bit more to improve the application speed.

Hope this will help waiting for sunny's miracle ;)

Bests,
cutmaster
 
Posts: 104
Joined: Fri Jun 19, 2009 11:49 am

Re: Improve load time for application

Postby bsoft » Wed Jan 27, 2010 1:19 pm

Yes that's true. JQuery is not at all for iPhone.. too heavy.
That's why i'm going to try this framework http://xuijs.com/
And, if it still not good, i'll get back to old school programming.. with my document.getElement... etc.

More over, i'll try to add transition and effect no more with jquery, but with CSS3.

I think, after that, load time should be much better. (of course, i'm talking about 3G, not 3GS which is more powerful).

I'm going to test all those techniques on "myQuickGame Free". Now, with jquery, it takes about 10 to 15s on my 3G to load! :o
I will post my test results within this week i hope..
bsoft
 
Posts: 97
Joined: Mon Jun 29, 2009 9:54 am

Re: Improve load time for application

Postby cutmaster » Wed Jan 27, 2010 1:38 pm

I think loading time will not change at all (but also remember that running your application in Debug mode takes more time to load than by launching the application by yourself clicking on the iPhone icon).
Rewriting jQuery functions just help a lot improving page loading while changing inside your application (so the "white screen" effect becomes more or less invisible).
cutmaster
 
Posts: 104
Joined: Fri Jun 19, 2009 11:49 am

Re: Improve load time for application

Postby sunny » Wed Jan 27, 2010 3:06 pm

NKit.js file becomes pretty big, takes some time to load it too, did you try make a stripped copy of it? Just leave classes and functions you need (unused methods can be stripped too, except those who set this.id), for instance tab controller can be stripped to:
Code: Select all
function NKTabBarController() {
   this.setTabBarForPage = AddTabBarItem;
   CallNKitAction("ShowTabBarController");
}
function AddTabBarItem(page, title, image)
{
   CallNKitAction("AddTabBarItem?page="+page+"&title="+title+"&image="+image);
}

if you use it only to show tabs (no badges, positioning, etc).

Of course you should not modify file in /Library/Frameworks, make a copy of it and drag to your project removing original NKit.js from it (remove only references, not file itself or your other projects will be affected too and updating NimbleKit rewrite the file again)

This is just my guess that it will help improving loading time, not sure how much improvements it will bring, probably not even noticeable, but anyway worth to try.
Ah yeah, also there are utilities which strip unnecessary new lines and spaces, after you done with removing classes and functions you can run your copy of NKit.js through such utility and get more optimized version.

**UPDATE: You should do that only if you feel strong knowledge of what you are doing
User avatar
sunny
Staff
 
Posts: 1692
Joined: Sat May 30, 2009 5:18 am
Location: kiev, Ukraine

Re: Improve load time for application

Postby cutmaster » Wed Jan 27, 2010 5:34 pm

Yes I agree with Sunny,
Minifying a javascript could help loading it...
Also try to not have too much comments, unwanted tabs or space on both you javascript & html code.
The best approach is to have to version of your files, one version which is "source/development" and one which is "production" that contain only minifyied files.
You can use an online minifier such as http://jscompress.com/ to help you "compressing" the files.
Please also notice that it is really necessary to ONLY minify your file, not to compress it using a Packer which requires too much processor to unpack and that slow down your page loading.

Bests.
cutmaster
 
Posts: 104
Joined: Fri Jun 19, 2009 11:49 am

Re: Improve load time for application

Postby bsoft » Wed Jan 27, 2010 11:00 pm

Yes i know, i already tried it.
i did minify my JS with the google closure compiler. (http://closure-compiler.appspot.com/home)
But, as my files were lighter, without comments etc.. load time didn't really change.

This evening i tried to recompile myquickgamefree without any jquery.
I use CSS3 for little transition, and the rest of JS is enough simple to be used with common functions.

And.... it takes now 8sec for my app to load. It took between 10 and 12 before.
So, that's a good start... but it's still too long.

i will also try to purge NKit.js from unused functions. And why not minify it.. ? But not really sur it will be enough.

As you said Sunny, the bigger problem comes from the interpretation of html page. So maybe the good solution could be to use as less as possible of html components, when they exist as NK compoment. Per exemple, for button..

Or simply, be patient until release 1.7, and pray for u find THE big tips! ;)
bsoft
 
Posts: 97
Joined: Mon Jun 29, 2009 9:54 am

Re: Improve load time for application

Postby sunny » Wed Jan 27, 2010 11:06 pm

I will run tests for obj-c/js bridge but I think creating NKButton will take more time then html equivalent as it uses XMLHttpRequest
User avatar
sunny
Staff
 
Posts: 1692
Joined: Sat May 30, 2009 5:18 am
Location: kiev, Ukraine

Next

Return to How To...

Who is online

Users browsing this forum: No registered users and 1 guest