Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decouple resizer from interwiki #3

Merged
merged 19 commits into from
Jun 1, 2024
Merged

Decouple resizer from interwiki #3

merged 19 commits into from
Jun 1, 2024

Conversation

r74tech
Copy link
Member

@r74tech r74tech commented May 27, 2024

smlt and others added 19 commits August 4, 2023 13:06
Add scpfoundation.net support through Crom
Removes global-like flag variable that tracked whether to show the
interwiki. Flag started off and switched on when a translation link was
added. Resize attempts would no-op until this was the case.

Moving this logic from the resize function to the main interwiki script
means the resize functions are now logically independent of the
interwiki. When the resize function is called, the iframe resizes. It is
the interwiki's job to decide when to call the function.
As opposed to calling the debounced function with the Arguments object
as the sole argument
Currently, making POST requests [with a JSON content type](https://developer.mozilla.org/en-US/docs/Glossary/CORS-safelisted_request_header) means that the browser needs to make a [preflight request](https://developer.mozilla.org/en-US/docs/Glossary/Preflight_request) first, and that adds an additional request overhead. The preflight request itself doesn't add much load to the API server, and it probably doesn't add a _huge_ overhead to the client either, but with the server running out of a single geographic region, switching to a "CORS-safe" GET request would spare a good chunk of a second of latency for the end-user, depending on their location. In the long term, this would also open up the avenue for basic HTTP-layer caching.

Implementation-wise, GraphQL doesn't exactly have an official spec for interfacing with HTTP, but the Crom API's custom implementation follows [the guidelines](https://graphql.org/learn/serving-over-http), which includes a recommendation for making requests over GET. The accept header is there so that the browser doesn't serve the playground HTML instead (which it would if the accept included text/html or \*/\*). Couldn't use URLSearchParams with the ES5 limitation, but the alternative isn't so bad. Also, I drafted this in the GitHub editor, so I haven't actually tested this change.
@r74tech r74tech closed this May 27, 2024
@r74tech r74tech reopened this May 27, 2024
@ukwhatn ukwhatn merged commit 27088ad into SCP-JP:main Jun 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants