-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
♻️ Use Font Awesome icons without JavaScript on SSR pages
Exports the SVG icons to the resources folder for the Clojure backend to read. Adds the same CSS classes as the Font Awesome (FA) JavaScript library would normally add. Why: - Reduces the amount of unnecessary JavaScript dependencies. - The pages load faster, when the icons are rendered correctly immediately, instead of after the FA JS has finished loading. - We can avoid the workaround of hiding the page content before FA has loaded (i.e. has added the .fontawesome-i2svg-active class on body), which has the risk of breaking everything if FA breaks. https://docs.fontawesome.com/web/dig-deeper/svg-async - The SVG files were named according to how this application uses them, instead of how FA originally calls them. This will make it easier to switch individual icons, when the only line to change will be the import statement. - Instead of adding custom styling, as FA documentation advices when using bare SVGs (https://docs.fontawesome.com/web/add-icons/svg-bare), we use the same CSS as FA's JS library uses. This is to avoid minor differences in implementation. It also comes with .fa-rotate-90 and similar helper classes for basic transformations. - The solution uses Clojure macros to precompute the SVG images where possible, to speed up generating HTML. If the SVG has dynamically computed attributes, it'll fall back to preparing the SVG at runtime.
- Loading branch information
Showing
18 changed files
with
153 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.