4 ms·
This is the only JavaScript file they use [0]. It's a pure joy. [0] https://subreply.com/static/script.js?v=6 https://subreply.com/static/script.js?v=6
by andreygrehov 6y ago
This is the only JavaScript file they use [0]. It's a pure joy.
[0] https://subreply.com/static/script.js?v=6 https://subreply.com/static/script.js?v=6
- jekrb 6y agoThis takes me back to how we used to write JavaScript on websites for towns/cities at a company I used to work at. Really a joy to read.
- jcun4128 6y agoWhy do (almost) all the functions have event.preventDefault() ?
- postalrat 6y agoThey are probably submit handlers on forms and they don't want the default form submit to happen.
- dgb23 6y agoNot on desktop right now to inspect. But this is typically the most compatible way to prevent standard anchor and button (or others) functionality. If you want the specific answer you could inspect where these handlers are attached to and then check the MDN documentation for default behavior.
- webninja 6y agoOne possible use is to prevent the standard right click menu from showing on desktop so that a custom right click menu can be shown instead.
- moneywoes 6y agoSilly question but to help learn how should the JS file be done?
- retox 6y agoIt's short, readable and doesn't use any frameworks.
- 6510 6y agoIt is really a work of art. There are some things that could be shorter but it would be slightly slower.