News for hackers. Stuff that matters.
Re:A day without JavaScript by Sean1708 on Wednesday June 07, 2017 @08:53AM (#14505931)
I'd be very interested to see some proper analysis of the difference in speed between HTML/CSS vs just JS, it seems obvious to me that the former would be much faster but then again I know how often "obvious" things are wrong.
Re:A day without JavaScript by SquareWheel on Wednesday June 07, 2017 @01:31PM (#14508235)
As a very general answer, JS webapps will typically be slower on the first load because they require an extra step to show the content.

Subsequently loaded-pages or resources can be significantly faster in webapps however, as they can request (or generate) exactly what they need.

The problem of slow initial loads is being addressed by tools like React by offering server-generated pages on the first load, and then transitioning to JS-based loading for subsequent loads. This offers the best of both worlds.

Re:A day without JavaScript by thinkxl on Wednesday June 07, 2017 @10:11AM (#14506556)
Re:A day without JavaScript by SquareWheel on Wednesday June 07, 2017 @03:42PM (#14509312)
Would you prefer that Hacker News reloaded the page every time you voted on a comment?
Re:A day without JavaScript by thinkxl on Wednesday June 07, 2017 @09:27PM (#14511207)
I wouldn't mind. But it doesn't work that way, look:

https://vimeo.com/58808364

Re:A day without JavaScript by SquareWheel on Thursday June 08, 2017 @01:35AM (#14512131)
Interesting video, but it still seems to be a JS-driven technique?
Re:A day without JavaScript by kccqzy on Wednesday June 07, 2017 @09:40PM (#14511255)
Even without JS, there are tricks to make the upvote button work without refreshing the page. HN used to do this, not sure if it still does.
Re:A day without JavaScript by SquareWheel on Thursday June 08, 2017 @01:55AM (#14512204)
Do you have a reference to any of those tricks? Sounds interesting.
Re:A day without JavaScript by framp on Thursday June 08, 2017 @03:10PM (#14516372)
You could use a link with a background-image

<style>.vote-42:active{ background-image: url(/api/vote/42) } </style> <a class="vote-42">Vote</a>

Re:A day without JavaScript by SquareWheel on Thursday June 08, 2017 @03:56PM (#14516744)
I ran a quick test. That actually seems to work, at least in Chrome. Very cool!

https://codepen.io/anon/pen/weMwRz

Realistically, I'd probably never use it because it's so dependent on browser behavior, but still a cool alternative.