Skip to content

Conversation

@userquin
Copy link
Member

@userquin userquin commented May 29, 2025

Caution

I need to do some check about CORS when the web worker requires to fetch data from Iconify API

DONT MERGE YET 🙏 Looks like it is working 😍

Description

This PR adds a web worker moving all packing logic from main thread to the worker thread:

  • transfers the collections via ArrayBuffer to the web worker from main thread
  • moves all svg manipulation to src/utils/svg folder, exporting all helpers functions as a barrel: updated all static imports to use the barrel
  • updates all the VUE components using the old src/utils/pack and src/utils/icons modules to provide the proper collections: all collections or using the target collection
  • we need to figure out how to create the SVG Sprite, the logic still runing at main thread: maybe we can use the logic in this UnoCSS PR feat(preset-icons): Add CSS SVG Sprite support unocss/unocss#2675

supersedes #365

Linked Issues

Additional context

Including the new web worker (IconesPackWorker) adds an small chunk ~35KB

image
build output comparision with current version and using the web worker

image
IconesPackWorker in the devtools

@userquin userquin requested a review from antfu May 29, 2025 21:07
@netlify
Copy link

netlify bot commented May 29, 2025

Deploy Preview for icones ready!

Name Link
🔨 Latest commit 3a83a59
🔍 Latest deploy log https://app.netlify.com/projects/icones/deploys/6838ce36239e760008cb2c4b
😎 Deploy Preview https://deploy-preview-367--icones.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@userquin
Copy link
Member Author

userquin commented May 29, 2025

Looks like it is working, IIRC the service worker hacking also some CORS headers (https://github.com/antfu-collective/icones/blob/main/src/sw.ts#L23-L38):

image
removing the svg to force fetching the icon from Iconify API

image
service worker intercepting collection api call

image
network tab at devtools

@antfu antfu merged commit 2160370 into main May 30, 2025
7 checks passed
@userquin userquin deleted the userquin/feat-use-web-worker branch May 30, 2025 00:14
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.

3 participants