-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
preload_tag filter lacking crossorigin option #1738
Comments
you can get crossorigin set like this: |
Thanks Shyan, wasn't aware of that syntax. |
Tried it out, unfortunately it created a broken url with &'s in it (I've changed the domain name)
verses the original code: which generates a functional url:
|
hmm but it shouldn't matter when you click the font URL does it download successfully or works or given any error? To fix this, you can use the url_param_escape filter in Shopify Liquid to encode the URL. Try this code:
|
It raises this error: "Missing or malformed 'hmac' query string parameter" url_param_escape converts & to %26 which also results in that error. perhaps this is another use case for #1490 ? |
ChatGPT gave this solution:
which is then called via:
question is - where should you put the module code? |
I must have made an error in testing. Shayan's original suggestion did indeed work, closing. |
Hi there, I just wanted to add a few query to this thread as my query is related to preload_tag. Issue: When i use preload_tag for font that is hosted on https://fonts.shopifycdn.com, the preload_tag is throwing error "Input must be a theme or shop asset URL.". Code: Expected Output: Output: |
I have the following code, which theme-check is flagging as "For better performance, prefer using the preload_tag filter":
<link rel="preload" as="font" href="{{ header_font | font_url }}" type="font/woff2" crossorigin>
I tried using this liquid:
{{ header_font | font_url | preload_tag: as: 'font' }}
which generates this code:
<link href="not a real url" rel="preload" as="font" rel="preload">
But as its missing the crossorigin tag, this code isn't used due to CORS
Is adding the option to specifiy a crossorigin tag the correct approach?
The text was updated successfully, but these errors were encountered: