JavaScript VS Handlebars.js [closed] - javascript

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 are the benefits of using Handlebars.js, or any other such libraries, compared to just using JavaScript? So far I have not found anything in Handlebars that I cant do in just javascript.

JavaScript libraries make it easier and quicker to do things in JavaScript, anything a library can do, you can do yourself in JavaScript. But why would you? In pure JavaScript, if I wanted to select a element by id, I'd have to do this:
document.getElementById("coolId");
Or in JQuery (a JavaScript library) I could just do this:
$("#coolId");
It's quicker and easier than using pure JavaScript. Hence that's why I use JQuery to select elements and why I many different libraries - because they allow me to do things much quicker and easier than doing it myself in pure JavaScript, think of libraries as 'shortcuts' to achieving your goal functionality.
Edit: The drawbacks
However, whilst JavaScript libraries (generally) make our lives easier, as developers. They do come with drawbacks, including; large JavaScript files to download, taking longer for JavaScript engines to execute the code and, therefore, makes our code less efficient. For more on this, here are some links:
Advantages of using pure JavaScript over JQuery
What are the advantages and disadvantages of different JavaScript libraries?
The Pros And Cons Of JavaScript Micro-Frameworks
Thanks to Lix for the reminder.

Related

Traveling Salesman Problem implementation language [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 2 years ago.
Improve this question
i am trying to develop a web application using HTML, PHP, and java script and i will include the Traveling salesman problem. should i use python for implementation or stick to java script? and what is the difference between them? which one is less complicated?
This ultimately depends on which language you prefer coding it in. If you have much more experience in Python go with that if not stick to JavaScript. If you want a fast algorithm for traveling salesman. I think JavaScript is a lot more faster than Python. This also depends on what algorithm you implement. If you want an easy algorithm to code I would recommend the nearest neighbor algorithm. You can check out more algorithms here if you'd like to know more about that. https://en.wikipedia.org/wiki/Travelling_salesman_problem.
Traveling salesman is not an easy problem to solve efficiently. Luckily, Google, in its wisdom, has a robust implementation: https://developers.google.com/optimization/routing/tsp. So use that.
Adding additional languages to your application adds more complexity to your project. You already have two programming languages and a markup language in your project. Use javascript if you want to solve the problem on the client, or use php if you want to solve the problem on the server. If python is your language of choice, you can serve webpages from a python framework like flask instead of apache/php.

Drawbacks of including CSS and Javascript in HAML [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 7 years ago.
Improve this question
I need to change the design of various pages of a website developed in Ruby on Rails. I was thinking of modifying the HAML files to include CSS and Javascript to make the desining nicer and more responsive.
What could be the drawbacks of such an approach? I have came across such example here.
The drawbacks are exactly the same well known drawbacks of including anything but content in HTML.
Your muddling content with presentation and behavior. This leads down quick path to a total mess of inline everything and generally poor development practices.
Your CSS and JS will not leverage caching properly between pages that might otherwise share components.
Your CSS and JS will not be properly minified.
You will not be able to use code quality tools properly on CSS or JS.
The execution order of your JS is going to be confusing.
Your code indentation and quality in general will suck. This especially applies to HAML.
Other developers will hate you.
Rails even generates per controller stylesheets and scripts by default to make separating views from assets easier.
But in general the idiom of "per page" styles and behavior should be avoided unless you are creating trivial brocureware, you get better code quality and reuse if you try to envision a set of reusable parts or modules - HTML class attibutes are cheap - parsing a huge document with a junk drawer of CSS/JS is expensive.

Any reason for using JQuery over JS for simple tasks? [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
I'll keep my question short. I've read this question about a delay function.
How to wait 5 seconds with jQuery?
and it struck me that people wanted to know about alternative ways to achieve this using JQuery.
In my understanding JQuery is nothing but a JS library. In many cases to introduce new functionality.
Now why would someone use JQuery if an original JS function is available and not even too complex?
Bonus question: Can JS functions be called from within JQuery? (this one, if negative might answer my first one, actually...)
In my understanding JQuery is nothing but a JS library. In many cases to introduce new functionality.
Yes, that is correct. In fact, your astute observation that people want to use jQuery where JS will suffice likely stems from a lack of understanding to this point!
Now why would someone use JQuery if an original JS function is available and not even too complex?
Someone may wish to use jQuery for certain functions if the JS-only equivalent is not well supported in all browsers.
Bonus question: Can JS functions be called from within JQuery? (this one, if negative might answer my first one, actually...)
Certainly! As you stated, jQuery is just a JavaScript library, and can be mixed with bits of plain JS without a problem.

Can we do all things using native JavaScript rather than using 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 9 years ago.
Improve this question
Well nowadays I am learning jQuery. So I was just coding and I thought that is it possible to do all the things using JavaScript instead of using jQuery?
Yes, you can but you have to go through a long long way. But re-inventing the wheel is never a wise thing to do. The browsers does not know about the jQuery, jQuery is basically a javascript library, that exposes user friendly functions that have javascript behind them.
jQuery is a library written in JavaScript.
You cannot do anything in jQuery that cannot be done in JavaScript.
jQuery was designed to make client-side scripting easier, e.g. by using a CSS selector syntax to select DOM elements and the ease with which it could then traverse these and modify their content. It also irons out a lot of cross-browser compatibility issues (e.g. adding event handlers) and takes a lot of common tasks that require multiple lines of JavaScript code to accomplish, and wraps them into methods that you can call with a single line of code (e.g. AJAX).
But, at the end of the day, it's still JavaScript
jQuery is just a library written in Javascript, so yes - anything you can do in jQuery can be done in Javascript. It's not a different language, or interpreted by the browser in some special way - it's just javascript.

Learning/applying jQuery before JavaScript [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 9 years ago.
Improve this question
NOTE: I am not in any way asking whether or not I should learn JavaScript before jQuery. I understand that jQuery is simply a framework for JavaScript and as such JavaScript should be learned first.
I currently know HTML and CSS and I'm looking to expand into JavaScript. I have used several resources from tuts+ to treehouse to learn HTML and CSS, but recently I stumbled across a website called code school that I really enjoy using.
When I go to their JavaScript section, it appears they skip JavaScript all together and jump right into jQuery. My question is - should I learn JavaScript on some other website before learning jQuery on code school? Or do you think it's a good idea to just learn jQuery right out of the gate like they basically force you to do on their site?
jQuery is just a Javascript library. You can't use jQuery without knowing Javascript.
However, by following jQuery tutorials, you may be able to pick up enough Javascript to get along. But if this is the first procedural language you're using, you may also get very confused.
NetTuts, as good as it is for exposing a variety of different frameworks, is not a great place to learn jQuery or JavaScript. I would recommend getting your hands on some books referenced here:
https://stackoverflow.com/questions/11246/best-resources-to-learn-javascript

Categories

Resources