diff --git a/lib/module.js b/lib/module.js index e316c6d..641a4a1 100644 --- a/lib/module.js +++ b/lib/module.js @@ -3,7 +3,8 @@ const { resolve } = require('path') const defaults = { css: true, materialDesignIcons: true, - materialDesignIconsHRef: 'https://cdn.jsdelivr.net/npm/@mdi/font@5.8.55/css/materialdesignicons.min.css' + materialDesignIconsHRef: 'https://cdn.jsdelivr.net/npm/@mdi/font@5.8.55/css/materialdesignicons.min.css', + async: true } module.exports = async function module(moduleOptions) { @@ -11,11 +12,20 @@ module.exports = async function module(moduleOptions) { // Add Material Design Icons font if (options.materialDesignIcons !== false) { - this.options.head.link.push({ - rel: 'stylesheet', + const attributes = { type: 'text/css', href: options.materialDesignIconsHRef - }) + } + + if (options.async) { + attributes.rel = 'preload' + attributes.as = 'style' + attributes.onload = 'this.rel=\'stylesheet\'' + } else { + attributes.rel = 'stylesheet' + } + + this.options.head.link.push(attributes) } // Add css