Increase performance of ionic app - performance

I created ionic app but its performance is too slow on android devices.
How can I increase performance of my app?
I have used list item, side menu and not performing any animation or transition.

See, there are number of ways to improve performance of any ionic application.
I am facing the same thing and I did some research on google and I found very helping documents.
Some performance improvement techniques of them are as follows
Use Track by
track by is used to avoid useless DOM manipulation when using
ng-repeat
Change your code from that:
ng-repeat="user in users"
to:
ng-repeat="user in users track by user.id"
(if users have a unique id) or
ng-repeat="user in users track by $index"
if they don’t. $index is added by ng-repeat to each elements of your collection.
Use Loggers
Use loggers instead of console.log which decreases performance
Use optimized Loops
Try to use cached for loop as possible as you can instead of angular
forEach.
Use Native scrolling
Use native scrolling instead of JS scrolling.
Native scrolling can be enabled using overflow-scroll=”true” on your ion-content or using the $ionicConfigProvider provider:
angular.module('yourModule').config(function($ionicConfigProvider) {
$ionicConfigProvider.scrolling.jsScrolling(false);
});
There are many more tips given in following links. Please refer them.
http://julienrenaux.fr/2015/08/24/ultimate-angularjs-and-ionic-performance-cheat-sheet/
http://tombuyse.com/improving-the-performance-of-your-ionic-application/

Try this:
collection-repeat="user in users track by $index"
You can use collection-repeat to boost the scroll speed.

Related

Lighthouse Mobile scores does not cross 90 (currently ~85). Struggling from the past few days how to get this right

Mobile scores does not cross 90. The reason given: the main-thread work. But, I've even reduced the components being displayed by using "display: none" for certain section on mobile. Despite that doesn't alter at all. What should I be doing? The following link will yield the scores:
I was able to check your google page speed insight, I believe you are not able to cross 90+ because of Avoid chaining critical requests. If you are using WordPress. The solution is to install (https://wordpress.org/plugins/swap-google-font-display/) this plug in and it will take care of the issue.

Angular5 pass DOM object to ng-content

I'm newest in web.
I want customize default scroll-bar in ag-grid. I try use ngx-scrollbar for this. In sources ngx-scrollbar I found that ngx-scrollbar using ng-content for wrapping elements(link to github source file). If wrap ag-grid-angular element then scrolling even doesn't shows because content doesn't overflow ag-grid-angular content because oveflow happen in div with class .ag-body-viewport where using stock srolls. In order to achieve needed effect I wish pass DOM element with class .ag-body-viewport to ng-content of ngx-scrollbar. Is it possible?
More info here github issue but I don't use Nice Scroll or Perfect Scrollbar
I want use ngx-scrollbar because it has capability of customization.
UPDATE
I can pass DOM element to ng-content using next sintax(agGridViewport is native element):
<ng-scrollbar>
{{ agGridViewport }}
<ng-scrollbar>
but it pass element like a copy of real DOM object but I want pass this like a refence.
Now I got UI like a stack style:
[rendered real ag-grid-angular]
[rendered ng-scrollbar with his content]
But it isn't that I need. Also I got bad rendering with artifacts and even some components doesn't appear. Now I want to try use Renderer2 for putting ng-scrollbar element between two DOM elements in tree(.ag-body-viewport-wrapper and .ag-body-viewport). But I think it's very bad idea because Renderer2 doesn't have methods for putting elements between DOM elements in tree and my code will be very unlify and complicated :( It's must be like injection.
No, I can not do injection in DOM with Angular tools. It's bad idea do it and it is not possible now. AgGrid doesn't support customization with tools like ngx-scrollbar which using ng-content for wrapping components and other elements. May be better way using other tools which working by another way or using webkit customization which supports not all web browsers.
UPDATE
Also I try to use smooth-scrollbar. I managed to get better result. I bind him to element .ag-body-viewport. It works fine but it scrolling only content of grid without header be careful. smooth-scroll bar doesn't have options for horizontal and vertical scrollbar as a different units. I know how issue can be solve. Vertical scrollbar must be bind to .ag-body-viewport and horizaontal scrollbar must be bind to .ag-root. If your can find scrollbar which let you do it that you can solve this problem. May be I write special component for Angular in near future and then add link to this answer. If you do it faster you can add yourself link or you can add link to already existing packages.

Ember.Select view rendering performance

I have an issue with Ember.Select views taking really long to render. Ember Inspector gives me rendering times of around 20-30ms for vanilla built in Ember.Select views (http://emberjs.com/guides/views/built-in-views/). That's fine with one or two Select fields but really adds up when you go beyond a few of them...
Here is an example of a basic Select JS Bin: http://jsbin.com/xawak/10/.
Are there any best practises to get around this?
Its an issue of the ember JS select component which unfortunately has up until 1.8.0 still not been resolved. The problem is probably caused by the fact that the component sets up bindings for each option of the select which is an expensive operation.
There is an issue for this already.

one page design

What if use just one html page with blocks inside,
like following
<div id="page1" style="display:block">...</div>
<div id="page2" style="display:none">...</div>
<div id="page3" style="display:none">...</div>
Active block has style="display:block" others "display:none",
when block becomes active "display:block" previous goes "display:none".
AJAX server communication, for instance
$.post("json", { "name": $("#name").val(), "sex": $("#sex").val() },
function(data) { console.log("server responded", data); });
What are disadvantages of this approach?
this is fast and dynamic but this approach lacks of no bookmarking facility, user can't save a particular link because the data is dynamic, also it is not search engine friendly, another disadvantage is history button back and forward will not work.
There are no disadvantages to using pure AJAX. In fact, in a lot of ways, its advantageous.
If you don't plan for it correctly you can have some issues. For example, you're used to having CSS effect 1 page at a time, but with pure AJAX, the CSS will affect every single page.
Also, all things become slightly harder. Linking to another page becomes harder, as you have to use JavaScript.
Lastly, your APP will now REQUIRE JavaScript, so I'd have a decent fallback.
This approach is used in some mobile Web frameworks, such as jQuery Mobile, and is intended to make a Web application feel more native. This is more Web 2.0 than traditional websites or web applications where each page transition involves a trip to the server.
I'm sure you know the advantages already, so let's move on to the disadvantages.
Slightly Greater Initial Latency:
The main disadvantage of this approach is that it will take slightly longer to load the page content due to the fact that you're getting all of the HTML from the server in one single trip. Thus, the initial load time may involve more latency than in a traditional Web 1.0 application. However, with just a few pages, in my experience, the latency is not significant enough for it to be a problem.
Loss of Back Button - More Complexity in Maintaining History:
Another potential disadvantage is that, as a developer, you'll need to approach the development of your site differently. Because you're transitioning pages by hiding one DIV block and unhiding another, you'll lose native back button functionality. This can be mitigated by using the hash in the URL to record the history of page transitions. You'd then need to register an event to watch the hash and reload old content as the user navigates backwards. You'd also need to change the state of JavaScript objects and variables to refect the old state, which may add complexity to your app. There are of course API's and libraries to make this easier to implement and help ensure that you write good, maintainable code.
More Stateful Scope Involves Rethinking Approach and Possible Learning Curve:
Lastly, you'll need to remember that the scope of each page doesn't reset after each transition. While this could actually be an advantage in that your app is more stateful, you'll need to untrain yourself in the way of thinking that each page loaded will cause all of the JavaScript variables and data you've set to be cleared out.
Summary:
My suggestion, if you're going to go this route, is to use a library. Don't reinvent the wheel unless you have a good reason to. Libraries, like jQuery mobile, help ensure that there is good fallback for older browsers, and some even make sure that your site will still load using Web 1.0 techniques for cases where JavaScript is disabled.

Bing image search paging - infinite scroll

When you search for images on the Bing search engine, the result is displayed like this:
http://www.bing.com/images/search?q=stack+overflow
Notice how you can keep scrolling and scrolling and there is not "normal" paging.
My question is: How do they do this? I can see there is some ajax/javascript events happening, but the code is not easy to read. I especially would like to know how they know when an "empty box" is inside the users view port.
After some searching and reading I found this very good site:
http://www.infinite-scroll.com/
It includes downloadable WordPress and jQuery -plugins and also explains pros/cons of using "Infinite scroll/autopagerize/unpaginate/endless pages"
Sample pseudo/jQuery code to load more data when user has scrolled all the way to the bottom:
$(window).scroll(function(){
if ($(window).scrollTop() == $(document).height() - $(window).height()){
loadMoreRows();
}
});
Here's an article about that technology :
Eliminate paging results by using JavaScript (ala DZone) : Using Javascript, prototype and PHP.
This feature is often called "infinite scrolling". Searching for infinite scroll javascript turns up a number of articles/posts on how to do this. Some of the more interesting ones:
Implementing infinite scrolling with jQuery
infinite-scroll.com
Continuous scrolling pattern using JavaScript and ASP.NET
Today I found a jQuery plugin that does the same scroll as Bing/Live Search:
http://blog.yctin.com/archives/jquery-plugins-ajaxscroll/
It was designed to remove the need for Next/Previous buttons.

Resources