0.1.1 • Published 2 years ago
@tycrek/facked-awesome v0.1.1
facked-awesome
Font Awesome interceptor middlware thing
facked-awesome is an Express middleware for easily loading Font Awesome from the server side... as I write this, I see less reason for it to exist...
Usage
Install with npm i @tycrek/facked-awesome
. In your code, simply use it as a middleware for any route you want to load your Font Awesome kit with.
// Set up your Express app as usual, then at some point:
const { facked } = require('@tycrek/facked-awesome');
// Use your Kit ID from Font Awesome. This can be found in the <script> URL they provide.
const kitId = 'abcde12345';
// Use facked as middleware
app.use('/facked.js', facked(kitId));
Now on the frontend, instead of loading your Font Awesome URL, you can load whatever path you provide here on your own server.
Buht mah perfohrmahnce!
Don't worry, facked-awesome keeps a cache of the Kit JS. If you do not want to use the cache, you can set the optional cache
parameter to false
.
app.use('/facked.js', facked(kitId, false /* Do not use cache */));
Does this middleware still increase processing time since it's loading the Kit JS from the server, rather than the client? Absolutely.