Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Support cross-origin stylesheets when CORS enabled #248

Open
flackr opened this issue Feb 14, 2024 · 2 comments
Open

Support cross-origin stylesheets when CORS enabled #248

flackr opened this issue Feb 14, 2024 · 2 comments

Comments

@flackr
Copy link
Owner

flackr commented Feb 14, 2024

In #78, @calinoracation mentioned that there are cases where external stylesheets are used from CORS-enabled origins, where it would also be nice to support scroll driven animations.

We could one of the following:

  1. Have some kind of allow list or option to change the behavior. This would be an exposed API surface that is not part of the public scroll driven animation API, or
  2. Have a build preference that changes the above behavior, or
  3. Try to load the stylesheet anyways and fail gracefully if it's not CORS-enabled.

I think I'm leaning towards option 3 as it seems simplest.

@calinoracation
Copy link
Contributor

I personally like option 3 as well. My only real concern is the potential for it to blow up alerting systems that might be listening to fetch failures globally and reporting on them. That's probably a reasonable thing, but it might also lead to a bit of unexpected perf hits.

For example all of the google fonts come via external stylesheets and would all be parsed in this manner, as well as any other externally injected stylesheets from ad servers and such.

Not saying I'm advocating for option 1, but it has some additional advantages:

  • Allows consumers to restrict only the origins we know should be parsed
  • Allows consumers to import the package but then schedule addition of the polyfill perhaps after first meaningful (to product) paint
  • Gives a new configuration point for example if we want to split up the CSS / JS parsing options in the future as is already proposed

The build preference for it could also be one that uses those options, but it doesn't seem as appealing to me. Feels like either get all the good stuff out of the box on import or you want to take a more manual approach.

@bramus
Copy link
Collaborator

bramus commented Feb 15, 2024

An allow-list defaulting to * seems the most practical to me. Works out of the box for most, allows finer configuration for those who want.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants