Last 12 weeks · 197 commits
4 of 6 standards met
closes #11915 test Please don't delete this checklist! Before submitting the PR, please make sure you do the following: [ ] It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs [ ] This message body should clearly illustrate what problems it solves. [ ] Ideally, include a test that fails without this PR but passes with it. Tests [ ] Run the tests with and lint the project with and Changesets [ ] If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running and following the prompts. Changesets that add features should be and those that fix bugs should be . Please prefix changeset messages with , , or . Edits [ ] Please ensure that 'Allow edits from maintainers' is checked. PRs without this option may be closed.
Describe the bug Dynamic environment modules cannot be used in Cloudflare Workers, which does not seem to be documented. Reproduction https://github.com/hyunbinseo/svelte-kit-15445 https://svelte-kit-15445.hyunbinseo.workers.dev/ Logs System Info Severity serious, but I can work around it Additional Information _No response_
Repository: sveltejs/kit. Description: web development, streamlined Stars: 20314, Forks: 2221. Primary language: JavaScript. Languages: JavaScript (99.5%), TypeScript (0.3%), HTML (0.1%), Svelte (0%), Shell (0%). License: MIT. Homepage: https://svelte.dev/docs/kit Topics: hacktoberfest, svelte. Latest release: @sveltejs/kit@2.53.4 (23h ago). Open PRs: 56, open issues: 949. Last activity: 20m ago. Community health: 75%. Top contributors: Rich-Harris, github-actions[bot], benmccann, dummdidumm, renovate[bot], teemingc, ignatiusmb, elliott-with-the-longest-name-on-github, dominikg, gtm-nayan and others.
JavaScript
closes https://github.com/sveltejs/kit/issues/12664 TODO Previously: This PR separates the client-side page preloading logic into its own module, which is dynamically imported after the app has started. However, I'm not sure if the trade-off is worth it, or rather, I'm not sure how to measure the impact of this. Pros: 1. 300 bytes less transfer size if your browser supports data saving mode and its enabled 2. Less code to parse before the page loads? Cons: 1. 1 KB more transfer size with data saving mode off or unsupported 3. Also, an additional network request for loading the preload code separately Turns out the transfer size of the client module with the preload code in the same chunk is smaller than having both in separate chunks. Please don't delete this checklist! Before submitting the PR, please make sure you do the following: [ ] It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs [x] This message body should clearly illustrate what problems it solves. [ ] Ideally, include a test that fails without this PR but passes with it. Tests [x] Run the tests with and lint the project with and Changesets [x] If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running and following the prompts. Changesets that add features should be and those that fix bugs should be . Please prefix changeset messages with , , or . Edits [x] Please ensure that 'Allow edits from maintainers' is checked. PRs without this option may be closed.
Describe the bug It can be seen here that the listener is attached inconditionally whenever the setup_preload function is called https://github.com/sveltejs/kit/blob/873ec2b4d559adb969148113fe883696cf00fa0a/packages/kit/src/runtime/client/client.js#L1500-L1512 The functions is always called unless is true While the annoyance is minor, its effects are perceptible as I found it because moving the mouse on sveltekit sites induce static noise in my loudspeakers and in my wired headphones, a sound I already relate with a cry for help from the event loop as it is also induced by other common but bad JS practices that clog the event loop with very short but periodic tasks like driving (usually clunky) animations by using . This is a devtool recording of ~3s of moving my mouse over the website. There is no JS activity on that page other than that generated by the event listener. !image While I don't think this is the most important thing in the world to change I don't think inconditionally attaching an event listener that serves no purpose if you don't use the feature it is meant for and causes subtle but ~~visible~~ audible side-effects on a page whose only JS is the routing/preloading code is the right thing to do, specially on a framework using Svelte, which is usually picked because it has the "you don't pay for what you don't use" philosophy of most compilers. Personally I would like a way to opt-out of this behavior by being able to specify which ways of preloading can be used within the app and defaulting to all of them. Another option for those who want to preload on hover but do not want to attach a global event would be being able to choose different strategies at compile time for . An alternative stategy would be attaching listeners to the elements with the attribute themselves. Maybe using (unsupported by Safari) can be helpful with performance so that other JS is not slowned down if there are lots of element to attach to. This way you can even use self-removing listeners if the is on the link itself. Reproduction https://kit.svelte.dev (happens on any svelte-kit website unless csr is disabled) Logs _No response_ System Info Severity annoyance Additional Information _No response_