Show HN: Social network that looks and works more like a forum
Some technical review from impressions.<p>You’re loading about 430KB of JavaScript. That’s quite a lot to parse and execute (yeah, less than many sites, but judging by the functionality it could probably be under 20KB for people just reading the site—code splitting, and all that). Gzipped, it’s over 70KB. Feeding it through Terser to minify the code (which achieves much more than just joining the lines), you can trivially cut it down to about 370KB with no breakage, and treating it as a module (so that it can mangle top-level names) reduces it to 230KB&#x2F;50KB, which would execute distinctly faster, except for the minor matter that everything will break because event handlers are routinely expressed as strings, including function names (and that’s probably the biggest reason why you should separate event handlers from markup).<p>You’re reimplementing various things that the browser provides, badly. A few examples:<p>• &lt;a href=&#x27;javascript:…&#x27;&gt;. This is <i>always</i> bad. Either use a link with a meaningful non-JavaScript href that will work with things like Ctrl+click&#x2F;open in new tab and possibly add a click handler that will event.preventDefault() and do something different for the current tab (though for general navigation in SPAs it’s normally easier to attach just one “in-app link” interceptor on the document root), or use a button with a click handler.<p>• &lt;div onclick&gt;&#x2F;&lt;span onclick&gt;. This is almost always bad (use an element with click semantics, such as a link or a button), and always bad if the element is not focusable by keyboard (e.g. by the tabindex=&quot;0&quot; attribute). When it’s &lt;span onclick=&quot;javascript:appSwitchPage(&#x27;&#x2F;conversation&#x2F;xjbjpgpqrpvutlf8wcgz1gt50&#x27;)&quot;&gt;, well, that’s even worse than &lt;a href=&quot;javascript:appSwitchPage(…)&quot;&gt;. Your approach there should be closer to &lt;a href=&quot;&#x2F;conversation&#x2F;xjbjpgpqrpvutlf8wcgz1gt50&quot; onclick=&quot;event.preventDefault();appSwitchPage(this.href)&quot;&gt;, though again I say one root link interceptor is generally a better approach.<p>• History management: you’ve implemented your own back button, a strange choice in general (why not use the browser’s like everyone else? For some sorts of apps, an <i>up</i> button that takes you to the parent in a hierarchy can make sense, but I can’t immediately think of any reasonable case for a back button), but your history management also just interacts badly with the browser’s own, with your back button adding a new history entry, and clobbering history when the native back button is used.<p>• Page loading: every time you load a page, you use your own loading spinner, and don’t cache various things that reasonably could be. This is a <i>massive</i> regression in experience from the traditional MPA&#x2F;server-generated HTML approach, where you tend to stay where you are, with only a small indicator that things are happening, until it’s ready and changes over. The end result of all of this is that this site <i>feels</i> much slower to load than it should, and that every load is painful and very disrupting. I’m in Australia, by the way, so add about 150ms on to whatever you may be used to—though the responses seem to be slow enough that latency doesn’t dominate it.<p>Other issues:<p>• Relative time display looks to be anchored to when you loaded the page&#x2F;app, not when you loaded a particular view&#x2F;page. This leads to times being wildly wrong, including future times (“-1234 seconds ago”). The problem looks to be the way settings_timestamp is used.<p>• The style of the code leads me to be concerned about injection attacks; in most places, the client is mixing template markup and responses from the server as raw HTML, thereby trusting the server to protect against malicious markup. I tried creating an account with values like &lt;script&gt;alert(&quot;xss&quot;)&lt;&#x2F;script&gt; for name&#x2F;alias&#x2F;bio&#x2F;whatever, name netted me a crash on &#x2F;settings&#x2F;me when I click on the value which shows &lt;script&gt;alert(&quot;Name&quot;)&lt;&#x2F;script&amp;, “SyntaxError: missing ) after argument list”. I’ve gone no further.