Split css into above and bellow the fold content.
There is no npm installer for now.
Copy grunt-abovethefoldcss to node_modules folder
checkout testpage repo for a simple example
sample options and npm task
abovethefoldcss: {
options: {
css: 'path_to_css.css',
aboveTheFold: 'path_to_above_the_fold_file.html',
useEmptyStyleTag: true,
sassPattern: "/*!ABOVE_THE_FOLD */"
},
build: {
}
}
grunt.loadNpmTasks('grunt-abovethefoldcss');
<style datafor='abovethefold'></style>
sample css, everything inside each /!ABOVE_THE_FOLD/ comment will be removed from the css file, and put on the above the fold file
/*!ABOVE_THE_FOLD*/
.person
display: block
.person__eyes
border-radius: 10px
/*!ABOVE_THE_FOLD*/
.person__eyes--blue
background: blue
/*!ABOVE_THE_FOLD*/
.person__body
font-weight: bold
/*!ABOVE_THE_FOLD*/
this file is the main css file after being compiled by sass
this file is the above the fold container, it can either be an html file and replace the styletag, or an empty file and use a server side include to load it to the head
this defines the aboveTheFold behaviour. If true (default) it will compile into style datafor='abovethefold'. If false it will replace the aboveTheFold file contents
This is the empty styletag on the html file, by default: style datafor='abovethefold'.
This is the comment pattern inside the sass file, remember to include the ! as this makes sure the comment gets passed to the css