GithubHelp home page GithubHelp logo

theme-next / hexo-filter-optimize Goto Github PK

View Code? Open in Web Editor NEW
45.0 14.0 2.0 73 KB

A Hexo plugin that optimize the pages loading speed.

License: MIT License

JavaScript 100.00%
hexo plugin filter optimize hexo-plugin

hexo-filter-optimize's Introduction

hexo-filter-optimize

travis-image npm-image lic-image

A hexo plugin that optimize the pages loading speed.

It will auto filter your html file, find the <link rel="stylesheet"> block and replace them into a javascript to optimize CSS delivery.

And inline the main.css into the html page like @maple3142 does.

It will improve your pages loading and get a higher score in the Google PageSpeed Insights.

Known Issues: This plugin may cause Font Awesome and PJAX to fail to load.

Installation

size-image dm-image dt-image

npm install hexo-filter-optimize

Usage

Activate the plugin in hexo's _config.yml like this:

filter_optimize:
  enable: true
  # remove the surrounding comments in each of the bundled files
  remove_comments: false
  css:
    # minify all css files
    minify: true
    # bundle loaded css files into one
    bundle: true
    # use a script block to load css elements dynamically
    delivery: true
    # make specific css content inline into the html page
    #   - only support the full path
    #   - default is ['css/main.css']
    inlines:
    excludes:
  js:
    # minify all js files
    minify: true
    # bundle loaded js files into one
    bundle: true
    excludes:
  # set the priority of this plugin,
  # lower means it will be executed first, default of Hexo is 10
  priority: 12

This plugin can be disabled by NODE_ENV in development to boost hexo generate:

export NODE_ENV=development

Comparison

Here is a result from GTmetrix to show you the changes between before and after. (Same web server located in Tokyo, Japan, vultr.com)

  • Remove query strings from static resources - let all the proxies could cache resources well. (https://gtmetrix.com/remove-query-strings-from-static-resources.html)
  • Make fewer HTTP requests - through combined the loaded js files into the one.
  • Prefer asynchronous resources - change the css delivery method using a script block instead of link tag.
  • And TODOs ...

Comparison

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.