From 6b648a7c9000b7f80f8b7de2ab21a344ef06b5b2 Mon Sep 17 00:00:00 2001 From: Nathaniel Watts Date: Sat, 22 Sep 2018 20:21:50 -0500 Subject: [PATCH] Edit README (#176) --- README.md | 483 +++++++++++++++++++++++++++++------------------------- 1 file changed, 260 insertions(+), 223 deletions(-) diff --git a/README.md b/README.md index 59a1512..859401e 100644 --- a/README.md +++ b/README.md @@ -4,14 +4,9 @@ > Easily enable fast AJAX navigation on any website (using pushState() + XHR) -Pjax is **a standalone JavaScript module** that uses -AJAX (XmlHttpRequest) and -[pushState()](https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Manipulating_the_browser_history) -to deliver a fast browsing experience. +Pjax is **a standalone JavaScript module** that uses [AJAX](https://developer.mozilla.org/en-US/docs/Web/Guide/AJAX) (XmlHttpRequest) and [pushState()](https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Manipulating_the_browser_history) to deliver a fast browsing experience. -_It allows you to completely transform the user experience of standard websites -(server-side generated or static ones) to make them feel like they are browsing an app, -especially for users with low bandwidth connection._ +_It allows you to completely transform the user experience of standard websites (server-side generated or static ones) to make users feel like they are browsing an app, especially for those with low bandwidth connections._ **No more full page reloads. No more multiple HTTP requests.** @@ -28,45 +23,48 @@ _Pjax does not rely on other libraries, like jQuery or similar. It is written en ```html ``` - Or the [minified bundle](https://cdn.jsdelivr.net/npm/pjax/pjax.min.js): + +- Or the [minified bundle](https://cdn.jsdelivr.net/npm/pjax/pjax.min.js): ```html ``` -## How Pjax works +--- -Pjax loads pages using AJAX and updates the browser's current URL using `pushState()` without reloading your page's layout or any resources (JS, CSS), giving a fast page load. +## What Pjax Does -_But under the hood, it's just ONE HTTP request with a `pushState()` call._ +_Under the hood, it's just ONE HTTP request with a `pushState()` call._ -Obviously, for [browsers that don't support `history.pushState()`](http://caniuse.com/#search=pushstate) Pjax gracefully degrades and does not do anything at all. +Pjax loads pages using AJAX and updates the browser's current URL using `pushState()` _without_ reloading your page's layout or any resources (JS, CSS), giving a fast page load. -It simply works with all permalinks and can update all parts of the page you -want (including HTML metas, title, and navigation state). +It works with all permalinks and can update all the parts of the page you want (including HTML metas, title, and navigation state). -- It's not limited to one container, like jQuery-Pjax is. -- It fully supports browser history (back and forward buttons). -- It supports keyboard browsing. +In the case of [browsers that don't support `history.pushState()`](http://caniuse.com/#search=pushstate), Pjax gracefully degrades and does not do anything at all. + +Additionally, Pjax: + +- Is not limited to one container, like jQuery-Pjax is. +- Fully supports browser history (back and forward buttons). +- Supports keyboard browsing. - Automatically falls back to standard navigation for external pages (thanks to Captain Obvious's help). - Automatically falls back to standard navigation for internal pages that do not have an appropriate DOM tree. -- You can add pretty cool CSS transitions (animations) very easily. -- It's around 4kb (minified and gzipped). +- Allows for CSS transitions (animations) very easily. +- Is only around 6kb (minified and gzipped). -### Under the hood +## How Pjax Works - It listens to every click on links _you want_ (by default all of them). -- When an internal link is clicked, Pjax grabs HTML from your server via AJAX. -- Pjax renders the page's DOM tree (without loading any resources - images, CSS, JS...). +- When an internal link is clicked, Pjax fetches the page's HTML via AJAX. +- Pjax renders the page's DOM tree (without loading any resources - images, CSS, JS, etc). - It checks that all defined parts can be replaced: - - If the page doesn't meet the requirements, standard navigation is used. - - If the page meets the requirements, Pjax does all defined DOM replacements. + - If the page doesn't meet the requirements, standard navigation is used. + - If the page meets the requirements, Pjax does all defined DOM replacements. - Then it updates the browser's current URL using `pushState()`. ## Overview -Pjax is fully automatic. You don't need to setup anything in the existing HTML. -You just need to designate some elements on your page that will be replaced when -you navigate your site. +_Pjax is fully automatic_. You don't need to change anything about your existing HTML, +you just need to designate which elements on your page that you want to be replaced when your site is navigated. Consider the following page. @@ -74,82 +72,115 @@ Consider the following page. - + + My Cool Blog + + + -
-
- Sha blah blah. +
+ +
+ +
+

My Cool Blog

+

+ Thanks for stopping by! + + Click Here to find out more about me. +

- -
+ + + +
+ © My Cool Blog +
+ - + ``` -We want Pjax to intercept the URL `/blah`, and replace `.my-Content` with the results of the request. -Oh and the `