A Cloudflare Worker that looks for Vimeo embeds on a page, and replaces them with the Lite Vimeo Embed facade.
- It's better for performance ๐
- It makes your page greener ๐๏ธ
Rather than loading the Vimeo player, and all the JavaScript that comes with it. This Worker replaces it with a facade. Vimeo's JS code gets downloaded when the user wants to use the player.
By default the Vimeo player downloads just around 250kB of data when it is loaded on a page. Using this Worker can reduce the initial size of your page by about 200kB per video (about 0.050 grams of CO2).
This Worker uses slightlyoff/lite-vimeo. You can adjust the script to use any of options available in that web component.
You can test this worker locally using Wrangler.
- Checkout the
demo
branch. - Run the
wrangler dev
command. - Open your browser and navigate the running local server.
- Using an extension like ModHeader in Chrome, set a new Request header
x-demo: <the URL you want to test>
.