Giter Site home page Giter Site logo

just use json about c4 HOT 16 CLOSED

aeosynth avatar aeosynth commented on August 16, 2024
just use json

from c4.

Comments (16)

qqueue avatar qqueue commented on August 16, 2024

patches welcome.

from c4.

vendethiel avatar vendethiel commented on August 16, 2024

actually making html5chan a proxy for 4chan o/

from c4.

qqueue avatar qqueue commented on August 16, 2024

proxy 4chan

I've thought about it. Serve from my own domain, wrap 4chan API calls on the server, etc. It would take some doing though, and would be in violation of moot's ill-enforced API guidelines.

In the meantime, rerendering the page is--for all but the largest (1000+ posts) threads--working pretty okay. I still want to extract my gross backlinking implementation out of the parser code, but it's otherwise fast enough.


Reposting from https://github.com/MayhemYDG/4chan-x/issues/756

@aeosynth why not just use the json api?

My DOM->object parser is already really fast, certainly faster than an HTTP request.

It's mainly my reluctance to use 4chan's HTML that requires the rerender. Mine has <article>s and shit, as well as eliding all of the mobile cruft. Also, since a lot of features like backlinks require massive DOM modification and reflow anyway, I just redo the entire documentElement (which has the added cool effect to completely disabling all page javascript, including the "native" extension).

@aeosynth but you do make an http request to load the current page; you could replace the one request with the other

You're right. I've been thinking about how to do pushState single page stuff to avoid having to keep replacing vanilla 4chan for every new thread. The fact that I (and I assume pretty much everybody else) opens up threads in new tabs nullifies any advantage though. However, that also means that the ~50-500ms per page rerender overhead is usually hidden in a background tab.

Another strategy would be to run the userscript on top of the .json pages since I don't need the original DOM for anything, but that would break the url for copying. Well, I guess there's the rotating logo, and moot news too.


Thus, I think I'd have to move to either my own domain or a "real" firefox extension before "just use json" becomes worth it.

from c4.

vendethiel avatar vendethiel commented on August 16, 2024

opens up threads in new tabs

yes

Another strategy would be to run the userscript on top of the .json pages

ugh.

from c4.

aeosynth avatar aeosynth commented on August 16, 2024

[json] would break the url for copying

see:

pushState

from c4.

vendethiel avatar vendethiel commented on August 16, 2024

what about new tabs ?
You want to remove all links to trigger the "page-changer" which will load from json ?

from c4.

qqueue avatar qqueue commented on August 16, 2024

Even with replaceState, all the links from the catalog pages would have to be rewritten to .json, which could then potentially be copied, and would then be broken for non-html5chan users.

I guess I could use google's technique of replacing the url on mousedown, but that's lame too.

from c4.

vendethiel avatar vendethiel commented on August 16, 2024

all the links from the catalog pages would have to be rewritten to .json

why

from c4.

qqueue avatar qqueue commented on August 16, 2024

Okay, I guess they don't if I use window.location redirects on all non-json pages, similar to archive redirection.

But, unless the browser runs document-start greasemonkey before it starts loading the HTML version of the page, the speed advantage is nullified there too.

What I would need is some way to hook into the 'new tab' process of firefox before an HTTP request is sent.

from c4.

aeosynth avatar aeosynth commented on August 16, 2024

so this is doable, you just have to decide if the trouble of rewriting links is worth the benefit of smaller downloads + no re-rendering

from c4.

qqueue avatar qqueue commented on August 16, 2024

Also, I'm assuming that greasemonkey will run and let you create a DOM on top of application/json, which I'm pretty sure works, but I haven't tested it. I think firefox wraps the text in a DOM, so parsing would be done with JSON.parse(document.body.textContent)

smaller downloads

I bet the difference here is really minimal, considering the HTML is gzipped anyway.

no re-rendering

You know, I'm actually not so sure about the difference now. Since I replace documentElement at document-start, firefox never attempts to render the original DOM (doesn't even pull the scripts or CSS), it only parses the HTML for DOMContentLoaded. So it's more of a re-parse rather than a re-render. I don't have metrics around vanilla 4chan or 4chan-X, but the true overhead of html5chan compared to them might turn out to be pretty small.

Back when I was using jQuery and handlebars there would have been more to discuss, but right now, I think the page load is actually fairly tight.

from c4.

aeosynth avatar aeosynth commented on August 16, 2024

extracting data at least is definitely easier with json than with html -> dom

from c4.

qqueue avatar qqueue commented on August 16, 2024

True enough. An imageboard microdata schema like tinyboard used to have would make parsing easier, but moot will never do that.

from c4.

aeosynth avatar aeosynth commented on August 16, 2024

i'm closing old issues

from c4.

vendethiel avatar vendethiel commented on August 16, 2024

guess I should do the same at some point :P

from c4.

aeosynth avatar aeosynth commented on August 16, 2024

it's awkward because some of the projects are still active, even if they have a huge backlog

from c4.

Related Issues (6)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.