Skip to content

static-dev/spike-pushstate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spike PushState

npm tests dependencies coverage

⚡ immediate page loads using pushState

Note: This project is in early development, and versioning is a little different. Read this for more details.

Why should you care?

If you are building a static site with multiple pages, which is a perfectly reasonable and straightforward way to build a site, you may be thinking "hey, how could I get my pages to load immediately like in a single page app, but without a buttload of javascript?" Well good news my friend, this is just the plugin for you!

Here's what it does. You install it into a spike project, then start it up. Now any link on the page that you have another template for will render immediately using javascript and update the url with pushState, instead of loading normally through http. These loads are just about immediate, making the site seems very very fast. If a link is clicked that does not map to another html page in your output directory, it will behave as usual. Pretty cool, right?

Installation

npm install spike-pushstate -S

Note: This project is compatible with node v6+ only

Usage

Just initialize it in your spike project as a plugin as such:

const PushState = require('spike-pushstate')

module.exports = {
  // rest of your config
  plugins: [new PushState()]
}

That will do it! By default it will match any file with a jade extension, and use the pushState override on it. However, if you want it to match a different pattern, like maybe only jade files in one specific folder, you can just pass the files option with a glob matcher as such:

new PushState({ files: '**/templates/*.jade' })

License & Contributing