Jul 5, 2022 2:22 AM
Hi there, can someone please tell me how to defer a CSS file that's linked to a Template.
Solved! Go to Solution.
Jul 6, 2022 1:55 AM - edited Jul 6, 2022 1:56 AM
But the problem is that I am not requiring the css file, I am injecting the css to a template
Jul 6, 2022 4:58 AM
@ashu125 you can simply unlink the css file there and then include it in the markup.
If you want more control over linked files you will need to HubSpot CLI and edit the module's meta.json file and use css_render_options -- you can find more details here https://developers.hubspot.com/docs/cms/building-blocks/modules/files
Jul 5, 2022 6:13 AM
Refer to this https://developers.hubspot.com/docs/cms/hubl/functions#require-css you will see there you can async a CSS file in the following way:
{{ require_css(get_asset_url("./style.css"), { async: true }) }}
Jul 6, 2022 1:55 AM - edited Jul 6, 2022 1:56 AM
But the problem is that I am not requiring the css file, I am injecting the css to a template
Jul 6, 2022 4:58 AM
@ashu125 you can simply unlink the css file there and then include it in the markup.
If you want more control over linked files you will need to HubSpot CLI and edit the module's meta.json file and use css_render_options -- you can find more details here https://developers.hubspot.com/docs/cms/building-blocks/modules/files
Jul 6, 2022 6:48 AM
Yeah, I can do that. Thanks a lot