Lately, I’ve been formatting my HTML code like this.
I think it’s easier to read. What do you think?
<!-- google maps -->
<script
async
defer
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyC0V0yDJBNvnaSVz3XCsm5Pyu91U14s4DcM&callback=initMap">
</script>
<!-- jquery -->
<script
src="https://code.jquery.com/jquery-3.2.1.min.js"
integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
crossorigin="anonymous">
</script>
<user-review
name="Erin O."
photo="/images/face-erin.png"
review="I am convenient because I require little markup to use effectively. Lorem ipsum dolor sit amet.">
</user-review>
It looks nice. I’d just be worried about it taking up too much space - having to scroll through ten pages of html instead of just two. But that’s how formatting is, a compromise between readability and compactness.
Isn’t this how coding should be like, easy to read?
That is how I’m planning to write my code.
It’s easier to read through 10 pages of code and find what you need clearly, than to hunt for it.
I’ve been doing the same since learning Angular and Vue, where HTML tags can get very attribute-heavy. Since we’re not writing code on tiny screens anymore, readability is superior to compactness. Space is virtually unlimited, developers’ time isn’t.
Helps cut down on clutter. All the HTML code above are just replaced by a single
<user-review
name="Erin O."
photo="/images/face-erin.png"
review="I am convenient because I require little markup to use effectively. Lorem ipsum dolor sit amet.">
</user-review>
with name, review and photo parameters passed on to it.
@geekysmurf This is the result of the Beautify… using the link you provided
<!-- google maps -->
<script
async
defer
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyC0V0yDJBNvnaSVz3XCsm5Pyu91U14s4DcM&callback=initMap"></script>
<!-- jquery -->
<script
src="https://code.jquery.com/jquery-3.2.1.min.js"
integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
crossorigin="anonymous"></script>
<user-review
name="Erin O."
photo="/images/face-erin.png"
review="I am convenient because I require little markup to use effectively. Lorem ipsum dolor sit amet."></user-review>
almost the same as my original.
<!-- google maps -->
<script
async
defer
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyC0V0yDJBNvnaSVz3XCsm5Pyu91U14s4DcM&callback=initMap">
</script>
<!-- jquery -->
<script
src="https://code.jquery.com/jquery-3.2.1.min.js"
integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
crossorigin="anonymous">
</script>
<user-review
name="Erin O."
photo="/images/face-erin.png"
review="I am convenient because I require little markup to use effectively. Lorem ipsum dolor sit amet.">
</user-review>