Open fourfivesix opened 9 years ago
I'll begin working on this.
i can try to work on it tomorrow or in two days, because i believe it will involve lots of script changes and incompatibilities.
@czaks yeah, I've been looking in this in the past couple of hours. Every ready()
event needs to be encapsulated in
InstantClick.on('change', function() { ready() });
Also, the site turns into a one-page app, so pages that use separate CSS like boards.php need to be changed to use one single sitewide CSS. I still don't know if this will break the style chooser, probably not.
In general most event handlers should be abstracted to .on() wrapped to a page level container object, mainly because it reduces the number of bindings drastically and automatically handles new content being dynamically inserted without having to rebind events.
otoh, this would degrade performance when actually dispatching the events, am i right?
If you're responding to me, no, because delegation leverages the event bubbling that's already baked into how browsers process events. It improves performance because it avoids clogging the DOM with potentially thousands of bindings.
https://news.ycombinator.com/item?id=7201353 Read the comments and the responses from the developer. As someone who's been doing web dev since 1999, my opinion is that AJAX is a great tool for backend form processing and feed retrieval, but as a complete replacement for a navigation stack, you're walking into a minefield.
My idea:
1) Make all the JS and CSS equal for all pages;
2) Make every script bind to onready(handler)
from main.js
;
3) Load every script only once in the first pageload with the data-no-instant
attribute;
4) Every time the page changes, call ready()
thus firing every js. Most of them will quickly return false because they're not on the right page;
@czaks would this degrade performance? @duanemoody what could go wrong? We can whitelist just a set of "safe" links, and it also only works on GETs.
I imagine that we would provide an option in the Options menu allowing the user to disable it.
The main reason for even investigating InstatClick is that there is currently a lot of complaints about 8chan's performance and this would cheaply improve it.
http://instantclick.io/
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.