JavaScript performance on hybrid apps [closed] - javascript

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I'm writing a hybrid app with HTML5, JavaScript and CSS for Android 4.0+ and iOS 7.0+. I was wondering: does JavaScript consumes much memory of the smartphone? Basically my script will: parse objects, handle events, Ajax calls, update the view, etc. I was considering about use jQuery o Angular.js too.
I'm focusing on performance and smooth experience.
Thanks!

As Ari Lerner writes about AngularJS in ng-book, "When we mix Angular into the flow, it extends this normal browser flow to create an Angular context. The Angular context refers specifically to code that runs inside the Angular event loop, referred to as the $digest loop." This is good for updating the view with a JavaScript library.
Both AngularJS and jQuery are extremely efficient, and can be used together to meet the needs listed above.
In my opinion, the optimal JavaScript library for mobile is jQuery Mobile.

https://docs.angularjs.org/misc/faq
Angular JS uses Jquery for some of its operations, and uses its own built in version if none is declared. I would suggest reading the documentation for a full grasp.

Related

Is it a bad practice to use jQuery in Angular? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
My question is the following. Should I avoid using any kind of jQuery code in Angular application as it seems legit to have only one thing interacting with DOM.
Another question is if anyone came across problems where he couldn't find any other solution but writing a quick hack with jQuery.
Thank YOU!
Yes it's a bad practice, but sometimes it will save you much time, especially when you are looking for a plugin,
Do it when necessary only, and keep a note to switch it back when other solutions are available.
The first thing you should do is to read this thread on SO "Thinking in AngularJS" if I have a jQuery background?. This will give you some perspective.
When it comes to Angular, it the model that drives the view and most of the times direct DOM manipulation is not required.
For example if you are using DOM manipulation to show\hide element, add remove class or set style, then better to use ng-show\ng-class\ng-style directive.
But there are cases when DOM manipulation is required and that is the time you write directives and either use jqLite or jQuery to manipulate DOM.
My suggestion would be to avoid jQuery unless you have to incorporate a jquery plugin that is dependent on jQuery.
While developing always look if the inbuilt directives that can serve your purpose. If not can jqLite be used to achieve what is desired. Your final resort should be jQuery.
Well it's just two large resources, which makes your app "heavy". Otherwise it's only a preference thing. Personally I don't use jQuery with any of the reactive frameworks (Vue, React nor Angular).
Remember that anything jQuery can do, you can do with vanilla JS.

Should I rewrite my entire JavaScript code into jQuery? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
I'm currently developing a web application and I was forced to use jQuery for some animations and other specific purposes, but still most of my code is written in JavaScript.
Should I rewrite these JavaScript modules if after all jQuery is being loaded every time? I know that in some cases it is better to use JavaScript instead of jQuery because it is faster and some other advantages but I'm already using jQuery throughout the page and I'm wondering should I use it everywhere instead of loading the whole library for few chunks of code.
Will there be any significant difference in the performance if the library is already loaded?
There won't be any difference, the Javascript speed is better. The performances wihout libraries still better. So keep your modules
Its up to you.
If you don't like to use any JS library, then you have code a lot.
The current jQuery v1.12.2(supports IE 6,7,8) size is 97kb. You use CDN version to reduce the loading time of it.
Will it affect the performance?? Yes, a bit it will do.
You didn't mention whether you are making any XMLHttpRequest;
if so, its better to use jQuery for better cross browser compatibility.

What is the best approach for navigating between pages in a mobile application [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
What is the best approach for changing pages in a multipage mobile application?
I have seen it done both ways (as shown below). I can't seem to understand which one is the best approach. Are there differences between the two?
$("#nextPage").load("myapp.html", function(){
alert("loaded next page!");
});
Vs..
$('#currentPage').hide();
$('#nextPage').show();
For the difference between what you've wrote in the question - see comment by #Japser, but in general:
I would say it depends on your app design, on "how far" you want to take it, on the framework you choose for developing it with (Sencha, jQuery Mobile, jQuery, Dojo, ...), etc...
If you "go simple", you can have 1 HTML file considered as your main page, and in it have a DIV which you will use jQuery's .load to replace its content with different content from other HTML files...
You can also use the jQuery Mobile approach for the same, which uses .changePage, etc... again, depending on what you actually want to do.
At the end, it depends on what you want to accomplish.
There is no one best approach.
And if you ever implement multi-page navigation in a Worklight-based project, it is highly important to remember that a Worklight application is a Single Page Application. You must not "leave" the Worklight context, or else you application will stop functioning. See more here: IBM Worklight 6.1 - Why is Cordova code not working when placed in a sub-page?

Why is AngularJS called a poor fit for GUI editor apps? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
While evaluating AngularJS for a project, I noticed the following paragraph in its documentation:
Games, and GUI editors are examples of very intensive and tricky DOM
manipulation. These kinds of apps are different from CRUD apps, and as
a result are not a good fit for Angular. In these cases using
something closer to bare metal such as jQuery may be a better fit.
But the docs continue without really explaining why this is so. In order to make an informed decision about what technology we use for our project, I'd like to better understand where this statement comes from and what facts are behind it.
What specific problems would hamper someone trying to build eg an illustration tool, or a video editing suite, in AngularJS?
This is a good question. Angular provides great declarative facilities for your run-of-the-mill web page work. To do this it relies on a watchers and constantly checks for changes on watched properties, then updates the UI with changes. The FAQ claims this process is "snappy" with hundreds or thousands of bindings which is good enough for most uses. Games and GUI editors can have complex interfaces with frequent or constant user interaction, so constantly re-evaluating a huge collection of watchers may not be the most performance-conscious way of doing things. Contrast this to a site like Stack Overflow where a user only clicks/presses something every few seconds and cause a re-eval of the watch list. Using a more imperative approach and library(jQuery et al) would cause less overhead.
Angular has a few limits that come into play here.
First, ng-view doesn't support nested views. So that limits more complex UI design.
Next a "GUI Editor" is usually built around the concept of widgets and dialogs. Angular is built around very different concepts. You can simulate widgets with directives somewhat. But it will feel like you're fighting Angular the whole time.
Basically nested scopes, isolate scopes, and declarative data binding aren't common paradigms for complex GUI work.

How to get started with jQuery Mobile? (Programmers background) [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I have a background in C++/C# and Java (Android). Now, I want to pick up what seems to me the best solution for mobile web applications: jQuery Mobile.
I know some of the very basics of HTML/DOM/CSS, but not in a structured/thorough manner.
Javascript-wise, it seems to be a rather different programming approach than I'm used to.
Where do you recommend I start? Javascript (and possibly Ajax) or jQuery or could I afford by immediately starting with jQuery mobile?
Plus, could you recommend me some good learning/example sources as well?
Thank you in advance.
-Thomas
jQuery mobile is a plugin written using jQuery in order to Enhance html5 elements appearance and behaviour to match iPhone design pattern for application behaviour (Progressive enhancement).
Whilst it is fairly easy to get started filling the templates jQMobile provides as a C# developer you need to understand that working with JavaScript and jQuery has some significant differences.
jQuery was a community necessity and is basically nothing but an abstraction layer on top of JavaScript to rectify the difficulties programmers were facing which mainly had to do with the difference of JavaScript implementation in different browsers and also the weakness in the DOM which is an API which allows JavaScript to access elements inside the document.
What jQ basically does is it takes care of those differences for you and exposes methods to you that are pretty much guaranteed to deliver the same results across supported browsers.
This will greatly help you get started by still wont allow you to learn the fundamental differences between the world you are coming from and the world you are getting into.
JS does not have classes only functions. However functions can have methods and be instantiated. The inheritance in js is Prototypal Inheritance.
new f()
produces a new object that inherits from
f.prototype
more info here
To learn the basics and understand more about this language before you use it! please watch this also

Categories