{"id":15488993,"url":"https://github.com/blakewilson/vidbg","last_synced_at":"2026-03-10T13:32:40.975Z","repository":{"id":37445104,"uuid":"44953131","full_name":"blakewilson/vidbg","owner":"blakewilson","description":"A minimal vanilla JavaScript video background plugin.","archived":false,"fork":false,"pushed_at":"2023-03-04T03:33:31.000Z","size":8238,"stargazers_count":115,"open_issues_count":6,"forks_count":29,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-01-03T02:19:56.687Z","etag":null,"topics":["es6","javascript","video","video-background"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/vidbg.js","language":"TypeScript","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/blakewilson.png","metadata":{"files":{"readme":"README.md","changelog":null,"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}},"created_at":"2015-10-26T07:39:48.000Z","updated_at":"2024-12-10T08:28:25.000Z","dependencies_parsed_at":"2024-11-07T17:02:21.758Z","dependency_job_id":"ce595628-9aaf-48cc-ac0e-7eb869be8b48","html_url":"https://github.com/blakewilson/vidbg","commit_stats":{"total_commits":99,"total_committers":4,"mean_commits":24.75,"dds":0.5252525252525253,"last_synced_commit":"753a3146f126aac5776df9dba856de8bfa2aeff7"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blakewilson%2Fvidbg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blakewilson%2Fvidbg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blakewilson%2Fvidbg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blakewilson%2Fvidbg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/blakewilson","download_url":"https://codeload.github.com/blakewilson/vidbg/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":233648598,"owners_count":18708223,"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":["es6","javascript","video","video-background"],"created_at":"2024-10-02T07:02:49.285Z","updated_at":"2025-09-20T08:32:45.573Z","avatar_url":"https://github.com/blakewilson.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# vidbg.js\n\nA minimal vanilla JavaScript video background plugin.\n\n## Compatibility\n\n- All modern web browsers\n- IE 11+\n- All mobile web browsers that support autoplaying HTML5 `\u003cvideo\u003e`\n\n## Working With Wordpress\n\nIf you plan on using vidbg.js with WordPress, make your life a little bit easier and download the plugin I made on the [Wordpress Repo](https://wordpress.org/plugins/video-background/).\n\n## Usage\n\n### Install\n\n```bash\nnpm install vidbg.js\n```\n\nOr [download the built `vidbg.zip` from GitHub](https://github.com/blakewilson/vidbg/releases/latest)\n\n### Instructions\n\nIn the browser:\n\n```html\n\u003c!-- \u003chead\u003e --\u003e\n\u003clink href=\"dist/vidbg.css\" rel=\"stylesheet\" type=\"text/css\" /\u003e\n\n\u003c!-- End of \u003cbody\u003e --\u003e\n\u003cscript src=\"dist/vidbg.js\"\u003e\u003c/script\u003e\n```\n\nOr if you are working with modules:\n\n```js\nimport vidbg from \"vidbg.js\";\n```\n\n### Initializing the Script\n\nThe script accepts three arguments.\n\n```js\nvar instance = new vidbg(selector, options, attributes);\n```\n\nThe selector argument is any JavaScript selector, the [options](https://github.com/blakewilson/vidbg/tree/v2#options) are for configuring vidbg.js, and the [attributes](https://github.com/blakewilson/vidbg/tree/v2#attributes) argument modifies the actual `\u003cvideo\u003e` element.\n\n```js\nvar instance = new vidbg(\n  \".vidbg-box\",\n  {\n    mp4: \"http://example.com/video.mp4\", // URL or relative path to MP4 video\n    webm: \"path/to/video.webm\", // URL or relative path to webm video\n    poster: \"path/to/fallback.jpg\", // URL or relative path to fallback image\n    overlay: false, // Boolean to display the overlay or not\n    overlayColor: \"#000\", // The overlay color as a HEX\n    overlayAlpha: 0.3, // The overlay alpha. Think of this as the last integer in RGBA()\n  },\n  {\n    // Attributes\n  }\n);\n```\n\nNote: Supplying both `.mp4` and `.webm` will increase browser compatibility.\n\n### Options\n\n```js\nconst defaultOptions = {\n  mp4: null,\n  webm: null,\n  poster: null,\n  overlay: false,\n  overlayColor: \"#000\",\n  overlayAlpha: 0.3,\n};\n```\n\n### Attributes\n\n```js\nconst defaultAttributes = {\n  autoplay: true,\n  controls: false,\n  loop: true,\n  muted: true,\n  playsInline: true,\n};\n```\n\n### Overlay\n\nSetting the `overlay` option to `true` will add an RGBA background over your video. This is helpful when you want to display text or meaningful content over the video background to increase legibility.\n\n### Fallback Image Flashing\n\nYou may experience the fallback image flash on page load. This is because the fallback image is added through JavaScript. As a result of this, it will load after CSS styles are rendered.\n\nIf you'd like to combat this, you can preset the fallback image through CSS. For example, if your selector is `.video-box` you could do something like:\n\n```css\n.video-box .vidbg-container {\n  background-image: url(/assets/link-to-fallback.png);\n}\n```\n\n### Methods\n\nBelow are the methods that are available:\n\n```js\n// First, create the vidbg.js instance.\nvar instance = new vidbg(\".vidbg-box\", {\n  mp4: \"http://example.com/video.mp4\",\n  webm: \"path/to/video.webm\",\n  poster: \"path/to/fallback.jpg\",\n});\n\n// Manually resize the video background\ninstance.resize();\n\n// Manually play the video\ninstance.playVideo();\n\n// Manually pause the video\ninstance.pauseVideo();\n\n// Get the video playing state\ninstance.isVideoPlaying();\n\n// Remove the \u003cvideo\u003e element\ninstance.removeVideo();\n\n// Completely remove the video background\ninstance.destroy();\n```\n\n## Media\n\nVideo and fallback image provided by Christophe Tauziet at https://vimeo.com/user27974867\n\n## License\n\nvidbg.js is licensed under The MIT License. You can view it [here](https://github.com/blakedotvegas/vidbg/blob/master/LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblakewilson%2Fvidbg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fblakewilson%2Fvidbg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblakewilson%2Fvidbg/lists"}