-10
What are the advantages and disadvantages of using HTML 5 instead of Javascript? Since, in Javascript we can do everything that HTML 5 can do, but the opposite does not happen...
References: HTML5,Javascript, GIFT
-10
What are the advantages and disadvantages of using HTML 5 instead of Javascript? Since, in Javascript we can do everything that HTML 5 can do, but the opposite does not happen...
References: HTML5,Javascript, GIFT
2
HTML5 is not an alternative technology to Javascript, it is a DOCTYPE, as I explained in:
But it’s also a term used by certain developers (which I disagreed with until I gave up debating) to refer to various technologies that came around the same time HTML5 started being supported by several browsers, for example:
--webkit-progress-bar
for <progressbar>
, whether or not standardized)So many times people use Html5 to refer to what is not HTML5, here on the site the tag is very used for this purpose:
If you look at the questions you will notice that many of them are questions about CSS and Javascript and not about HTML5 tags and their behaviors.
I personally find it very wrong this way of "referring" to technologies, because for me I sought to learn from the basics and not only live from Ctrl+c as many developers do (in various communities, national and gringas), it always sounds strange, it seemed to me at the beginning (maybe it still sounds like this) that actually the devs didn’t even know what they were talking about and generally didn’t even understand the basics of doctype
Almost all HTML5 tags that have "extra" functionality that came with HTML5 have communication API or events that can be "heard" via Javascript, so HTML5 is the markup language+new features and Javascript is "programming language" that can work these new features of each tag, for example if picking up tags <audio id="bar">
or <video id="foo">
can stop music or video played via Javascript:
function pararAudio()
{
var bar = document.getElementById('bar');
if (bar) bar.stop();
}
function pararVideo()
{
var foo = document.getElementById('foo');
if (foo) foo.stop();
}
So simply HTML5 are these tags and tags that already existed before, but people reference themselves in this way "erroneous" (in my opinion) to say that HTML5 is all that was ever quoted at the beginning of the answer.
HTML5 alone does not have the ability to control in a "programmed" way what you want, for example, create new tags, will have people who will quote absurd things like:
But what about Vue.js?
But what about the Angular?
But what about React?
As if they actually generate new tags on a stand-alone basis, but in fact these "frameworks" are not HTML5, they are a series of libs and structure that use HTML5 and Javascript (with their own languages being "transpilated" for Javascript and HTML)
2
There are already some questions about the DOM:
This is what matters for the browser to render the content. There is a simple basic form that manipulates it which is HTML. We can roughly say that it is the basic declarative API for this (I speak further below).
There are other Apis that do the same, one of them is CSS that is so important too (I’m not going to say that it is so simple because there is a lot of confusion in its conception), but there are others that many do not even understand that they are different things but also serve to manipulate the DOM.
Javascript is a programming language, so it is more imperative and allows to do many more operations, and since it has an API to manipulate the DOM in its standard library in the browsers it is possible to do much more powerful operations in this DOM manipulation.
In essence you can do everything on JS until for being a programming language. A markup (HTML) or styling (CSS) language can’t do everything (they even managed to put the two together and do more complex things, but in a crazy way, you can’t really use it like this).
No one or something forces you to use HTML, 5 or not, you can actually do everything with JS, and I even like the "idea". It may even be that the charge of scripts slightly depend on HTML, but only.
If you feel more comfortable with Javascript, don’t like HTML and think you can do better without using it leave everything to the JS can do if it is an application. I’m not recommending, but saying it’s possible.
If it is a website it complicates a little because the search engines will have difficulties to index the content of your site and it will not be found by people. Wish or accept this?
There’s a myth that these mechanisms understand JS, but it can’t perform everything as it would with the action of a human, so it might even be able to index the content in some way, but not everything, not correctly. There’s no way even with the bots modern who understand JS simulate all action and recreate what a human would do.
Also some browsers may be old or have some things disabled, for example the whole JS, which would make your pages not happen. Wants this?
Other than that it’s basically taste. Designers tend to have more ease with HTML which is a markup language and easier to understand than with JS.
Some people learn HTML well but JS not so much. It is common to see everyone doing everything they can with HTML and only goes to the JS when there is no other way, then other people copy these, so everyone learns more HTML than JS, it is viral, has more information teaching to use HTML first and then go to the JS. All this influences how people adopt technologies.
There is no talk of clear advantage or disadvantage, has one or the other according to the background of each, and what I said, if everyone uses HTML(5) can have help easier, have more examples, more recipes to follow, or be more intuitive for certain people (JS is more intuitive for me, but its weak API makes me think about using HTML, even though it allows me to do everything).
You can only use JS, but you have the right tool for every moment. Some want to use only JS so they don’t have to learn HTML. HTML is not difficult, manipulating the DOM is what it is, it has no way to escape, you will do with JS, HTML, CSS and other Apis.
We can still say that in a certain scenario it is a little easier to draw the page through HTML. A the nonpositional feature of the content favors a declarative form a little more than the imperative form of the JS.
It can be much simpler and have shorter code to make pages very simple (generally not very dynamic). And for the complex can decrease a little the complexity, even because few people know how to organize JS code to produce the same result.
It’s much more intuitive to do certain things in HTML than to create the same effect with JS. Roughly speaking, we can understand (not that it’s quite that) that HTML is sort of like ready-made functions that do some things. Have some parameterization (attributes), but is limited.
Limitation helps to be easier. That’s why people prefer to make it easier first (the initial content load) and when you need the power goes to the technology that allows this, the JS. One helps the other.
Not that I agree much with the way it is happening, but it is increasingly common in applications for people to almost abandon HTML, even by using components of frameworks Not that I don’t have HTML, but I have less than I had before. I don’t know. On the other hand they are using these web components as if they were native HTML (I’m talking about Angular, React, Vue and others, which are JS).
In my reading, this question indicates a kind of fundamental flaw in understanding what HTML is and what Javascript is - since you took the trouble to answer, maybe you could address this in the first few paragraphs.
Yeah, that’s why he asked. I even closed the question because the premise was bad, but then I realized that it was precisely because he did not understand that it should be answered.
Maniero sobre o SEO esse vídeo deve te interesse https://www.youtube.com/watch?v=4pOH8Smd0Xs está fresquinho é do Chrome Dev Summit que aconteceu esse mês. I know that Google is not unique, but considering that it is the search engine of more than 90% of Brazilians, I believe it has more strength in the SEO market...
@hugocsl if you’re saying that Google understands JS that’s always a lie, it understands, but it can’t simulate the actions that the user would do. If you know how to do it well, there’s no way Google can be wrong, but people don’t even know it, because they believe it’s just because the JS is there and everything will be perfect. It’s very hard to get it right, not by chance today this guy from SSR is so successful, especially to send to Google.
I’ll take this opportunity to ask feedback about the problem of the answer, only jsbueno said something, although I don’t understand why it deserves a negative, the problem may be in the question, but maybe it isn’t, as Woss questioned. I answered exactly what he asked and pointed out the wrong understanding that the AP have of the subject. If the problem is another then let me know to see if I correct or if I answer about the mistake that the person has on the subject that led him to deny, so we all win.
Anyway I tried to give an improved one to be more clear, who knows anyone think that now deserves no more negative.
Browser other questions tagged javascript html5 dom
You are not signed in. Login or sign up in order to post.
For those who voted -1, they could clarify what they saw wrong in the question and how they would suggest improving it?
– Woss
But taking advantage, Rodrigo, could give examples of what would be the "everything that HTML 5 can do" that Javascript also does?
– Woss
The question is too broad and unclear. In fact, I didn’t really understand what the AP meant as "what do I do in one with you do in the other"... What does he do in one and not in the other? What do you refer to?
– hugocsl
I answered because I found the question understandable, although starting from a flawed premise (in general who is learning commits this error). He wants to know why we don’t only use JS, because we can do this. Why there is HTML if we can build pages just by writing JS code. Instead of creating a
<div>
, can write a code create a division in DOM, can fill its contents, all with JS and nothing else. The same could be said of CSS. A very pertinent question that allows a simple explanation (I like to detail, but can be done in two small paragraphs)..– Maniero
HTML is a basic way of manipulating the DOM and it has a lot of limitation, usually just creating the nodes and assigning a value to it and filling its attributes. JS allows much more flexible and powerful handling.
– Maniero
An example of how to load a JS without any HTML would be good to support the thesis.
– Bacco
In short, HTML initially populates the DOM, and JS dynamically manipulates it. They’re related things, not competitors. I sincerely think that the post should be closed by starting from mistaken premises, in addition to lack of clarity and still a component of opinion. To make matters worse, it’s an area that most of you use doesn’t know what you’re doing, so it tends to turn into chaos. "Lucky" is that the first two answers were not parachutist, as is happening a lot on the site..
– Bacco