{"id":15649045,"url":"https://github.com/bluwy/svelte-fast-dimension","last_synced_at":"2025-04-07T16:18:49.624Z","repository":{"id":46085104,"uuid":"414695621","full_name":"bluwy/svelte-fast-dimension","owner":"bluwy","description":"Fast dimension bindings using ResizeObserver","archived":false,"fork":false,"pushed_at":"2025-02-09T01:31:13.000Z","size":241,"stargazers_count":42,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-31T15:18:14.129Z","etag":null,"topics":["resizeobserver","svelte"],"latest_commit_sha":null,"homepage":"https://npmjs.com/svelte-fast-dimension","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bluwy.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"bluwy"}},"created_at":"2021-10-07T17:23:20.000Z","updated_at":"2025-03-07T22:47:30.000Z","dependencies_parsed_at":"2024-04-04T03:23:03.367Z","dependency_job_id":"248ed450-b50e-4d20-9a2c-361100e7e0c9","html_url":"https://github.com/bluwy/svelte-fast-dimension","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bluwy%2Fsvelte-fast-dimension","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bluwy%2Fsvelte-fast-dimension/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bluwy%2Fsvelte-fast-dimension/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bluwy%2Fsvelte-fast-dimension/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bluwy","download_url":"https://codeload.github.com/bluwy/svelte-fast-dimension/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247685628,"owners_count":20979085,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["resizeobserver","svelte"],"created_at":"2024-10-03T12:27:30.994Z","updated_at":"2025-04-07T16:18:49.605Z","avatar_url":"https://github.com/bluwy.png","language":"JavaScript","funding_links":["https://github.com/sponsors/bluwy"],"categories":[],"sub_categories":[],"readme":"# svelte-fast-dimension\n\nFast [dimension bindings](https://svelte.dev/tutorial/dimensions) using ResizeObserver.\n\n\u003e [!NOTE]\n\u003e This package is no longer needed if you're using Svelte 5 as it now uses `ResizeObserver` itself.\n\n**Why?** Svelte 3 \u0026 4 used an iframe technique to measure dimensions so it works in older browsers. However, creating multiple iframes has a big performance impact and sometimes [quirkiness](https://github.com/sveltejs/svelte/issues/4776). If you already target browsers that support [ResizeObserver](https://caniuse.com/resizeobserver), this can significantly improve dimension binding performance.\n\n## Installation\n\n```bash\nnpm install --save-dev svelte-fast-dimension\n```\n\n## Usage\n\n```js\n// svelte.config.js\nimport { fastDimension } from 'svelte-fast-dimension'\n\nexport default {\n  preprocess: [fastDimension()]\n}\n```\n\nUse dimension bindings as usual, it will use ResizeObservers under-the-hood:\n\n```html\n\u003cscript\u003e\n  let a, b, c, d\n\u003c/script\u003e\n\n\u003cdiv\n  bind:clientWidth=\"{a}\"\n  bind:clientHeight=\"{b}\"\n  bind:offsetWidth=\"{c}\"\n  bind:offsetHeight=\"{d}\"\n/\u003e\n```\n\n## Recipes\n\n### Vite\n\n`svelte-fast-dimension` injects an import from `svelte-fast-dimension/action` when preprocessing. This won't be detected during Vite's prebundling phase, and will cause on-the-fly prebundling which slows startup time. To fix this, add `svelte-fast-dimension/action` to [optimizeDeps.include](https://vitejs.dev/config/dep-optimization-options.html#optimizedeps-include).\n\n## Sponsors\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://bjornlu.com/sponsors.svg\"\u003e\n    \u003cimg src=\"https://bjornlu.com/sponsors.svg\" alt=\"Sponsors\" /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbluwy%2Fsvelte-fast-dimension","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbluwy%2Fsvelte-fast-dimension","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbluwy%2Fsvelte-fast-dimension/lists"}