how to compress and minify assets using jekyll plugins

后端 未结 6 1663
滥情空心
滥情空心 2020-12-31 04:57

I have a simple test jekyll app like so:

index.html is:



        
相关标签:
6条回答
  • 2020-12-31 05:12

    There are plugins for HTML and CSS minification with Jekyll, but a search doesn't turn up anything obvious for JS.

    However, the source for CSS one above is less than 100 lines and actually uses Juicer to do the minification, which can also do JS, so that plugin could easily be used as a template to implement your own JS minifier (it looks like even just s/css/js/g would be close to working).

    0 讨论(0)
  • 2020-12-31 05:19

    Here's a summary of what I've found while solving this in 2014:

    Started with

    1. https://github.com/donaldducky/jekyll-cssminify

      Development was going well until it was beat by this project:

    2. http://www.matthodan.com/2012/11/22/jekyll-asset-pipeline.html

      ...which so far has been my favorite to implement, except it doesn't work now and it looks like development has been halted, so I was forced to turn to

    3. https://github.com/envygeeks/jekyll-assets

      ...which again, beats #2 but is just a touch trickier to use. Anyway, that's the only one that works, so that's what I'm using now.

    0 讨论(0)
  • This one seems fairly updated as compared to other plugins and minifies HTML/XML/CSS/JS Minifier utilising yui-compressor, and htmlcompressor
    https://github.com/digitalsparky/jekyll-minifier

    0 讨论(0)
  • 2020-12-31 05:22

    For JS and CSS you can use the Jekyll Asset Bundler It uses the yui-compressor or closure-compiler gems.

    0 讨论(0)
  • 2020-12-31 05:30

    For images, I made a drop-in plugin that runs the images through image_optim:

    https://gist.github.com/sffc/a828267913591159ab1cc3e1bfde20d7

    0 讨论(0)
  • 2020-12-31 05:31

    I recommend the Jekyll Asset Pipeline gem for this. It supports any language (e.g. Scss, Less, CoffeeScript, Erb, etc.) and has a bunch of features (e.g. asset tagging, compression, gzipping, etc.) that set it apart. It also seems to be the fastest growing Jekyll-related gem these days, which I take to mean that it is gaining traction in the community.

    0 讨论(0)
提交回复
热议问题