Speed up initial loading
We're developing an app which is partially native and partially hybrid. We will open cordova activity when user clicks on an menu item and finish the activity when user clicks back. Problem with this approach is, it takes a while to render on the screen for first time. We are hosting all the resource files in the assets folder so caching doesn't make much sense. Is there any progressive way to load the application?
Hi @jthoms1, will changes get merged with master before beta 11?
Yea I waiting offline compiling too, but something can be made now. Our site is completely on Ionic2 beta.8 http://m.sherpadesk.com/
I have hybrid app too and I did some optimizations and got 417ms loading time. Look at report https://tools.pingdom.com/#!/DW6Td/http://m.sherpadesk.com/17 Also Site size decreased 600% (3Mb -> 500 Kb) User interaction response speed improved 2000% (2 seconds -> 100ms)
Good recommendations: http://blog.angular-university.io/how-to-run-angular-2-in-production-today/36
I'll post all my gulp settings and link to appstore here: http://www.sherpadesk.com/blog/
@Evgeniynet very nice.
Few questions:
- When installing app it opens instantly but the. I get loading your profile and it seems to stuck for 5 sec. Why?
- How did you optimize loading time without offline compilation?
- Is your mobile website is ionic2?
- Is your desktop website ionic2?
I'm contemplating on using ionic 2 but the only thing which is stopping me that I need to manage webapp project + mobile ionic2 project.
Thanks
@evgeniynet is it served by node? It seems to be pre-compiled. But most of our case it will be device storage hosting (phonegap application).
@dheran, no, it is hosted on Azure website, only plain html and js files which produced by ionic 2 gulp build task.
@justme1
- yea, I did trick with http://www.bennadel.com/blog/3105-creating-a-pre-bootstrap-loading-screen-in-angular-2-rc-1.htm
Is your mobile website is ionic2? yes
Is your desktop website ionic2? yes
My ios app just loads site in webview, nothing more.
only one codebase for iOS, Android and Windows Phone, web app, Chrome extension and even an Apple iWatch
I set special flag to stop loading cordova, to prevent gap:// error
I am writing complete guide on this on http://www.sherpadesk.com/blog/
@evgeniynet
- It this is the case then it seems not really faster loading :-)
Regarding one codebase:
From what I understood ionic2 isn't supposed to be used as a desktop website as it's fully supported by browsers. Don't you mind this issue?
Count me in on waiting for this feature.
Hi, any updates on this? I'm using version: Cordova CLI: 6.3.0 Ionic Framework Version: 2.0.0-beta.10 Ionic CLI Version: 2.0.0-beta.35 Ionic App Lib Version: 2.0.0-beta.19 LG Nexus 5 (os 6.0) Sidemenu tutorial app v1 loads in 3 seconds --v2 sidemenu load in 6 seconds
The ahead-of-time compiling functionality is coming in Beta 12. This will dramatically speed up initial load and significantly reduce the size of the bundle. We're about to launch Beta 11, so this is up next. This is our #1 priority. We have it working on a branch, so we're close.
Thanks, Dan
its really slow for the first time. waiting for the optimization
@danbucholtz or anyone add this issue to beta 12 milestone
@danbucholtz can we use the branch code? Sorry, can't wait until beta 12 release.. :-( Please give us a quick release..
@dheran,
This change requires Angular RC 5 which isn't out yet. We will release it as soon as beta 12 is ready to go. We're not going to release until it's ready to go.
A good short term fix could be switching to use inline-templates as shown below. This will be faster short term. Give it a shot and see if it speeds things up for you some.
@Component({
template: `
<ion-content>
<div>content</div>
</ion-content>
`
})
export MyClass {
}
Thanks, Dan
@danbucholtz Inline actually helps a lot. I wrote a small code in my gulpfile.js which does that during build.
gulp.task('build', ['build:prequel'], function(done) {
glob('./www/build/**/*.html', function(e,files) {
var indexPath = './www/build/js/app.bundle.js'
var js = fs.readFileSync(indexPath, 'utf8');
async.eachSeries(files, function(file, callback) {
filename = file.substr(6)
var html = fs.readFileSync(file, 'utf8');
js = js.replace("templateUrl: '" + filename + "'", "template: `" + html +"`")
callback()
}, function() {
fs.writeFile(indexPath, js, 'utf8', function(err, data) {
done()
});
})
})
})
Yeah, this is not clean and is not the best way to do so. But it works like a charm.
PS: Inlining does not help a lot with initial startup, maybe at most 0.5 seconds. But it sure makes it smoother between page transition or whenever you are dynamically loading a component.
@prijindal, Nice! That's awesome! With the AoT compiler coming in Beta 12, it won't matter whether the template is inline or external file. It will be converted to pure JS as part of the build process. Nice work figuring that out!
Thanks, Dan
Hi, i checked Angular page and i see that RC5 is released. What did you mean by "until rc5 out"?
@kLkA , @dheran Give Ionic team a break - they sure are trying to get betas out as fast as possible and pinging everyday does not help them in any way. They are working directly with Google on Angular and definitely should know that Angular2 rc5 is out.
Yeah and Google released rc 5 like just few hours ago. I am sure they are aware of the release and are working something out to get it into beta 12