Enqueue external css

I want to enqueue an external CSS from Typekit (Adobe fonts). They provide a link like this:

<link rel="stylesheet" href="https://use.typekit.net/xxxxxxxxxxxxx.css">

How do I enqueue this external link with Bud?

  • Don’t use @import as it is blocking
  • I prefer to do it in with wp_enqueue_style, which you could add in the wp_enqueue_scripts action in app/

Something like this:

wp_enqueue_style('muh-font', 'https://font.saas/muh-font', false);

For non WordPress use of bud.js

In case someone is searching for how to do this outside the context of Sage:

  • Create an html file to serve as your application template.
  • add the <link> directly to the <head> element.
  • call bud.template() and pass it the path to the file you made:
export default async bud => {
  bud.template({
    template: bud.path(`index.html`)
  })
}
3 Likes