Day023 — PJAX

https://github.com/jacky-ttt

I used PJAX for faster page load, and build a nodejs project about that.

PJAX allows pages to only request and refresh the part that needed to be changed. The bandwidth required to deliver only a portion of the original whole page is smaller, thus the page load time is faster.

Below article explains what is PJAX and what it could bring to the table.

The first request to the server is a normal request (1). The server then returns the page in the normal fashion (2). The difference with PJAX is with subsequent requests. For example, if a user clicks on a link that opens the /about page the client-side JavaScript makes a request for only the parts of the page that need to change (3). The server then generates the html of the only the changed content and returns it in the response (4). The client-side JavaScript then replaces the old content with the new content.

— — — — — — — — — — — — — — — — — — — — — — — — — — —

I use this module for my nodejs project

— — — — — — — — — — — — — — — — — — — — — — — — — — —

simplified project using pjax(credit goes to the original author):

— — — — — — — — — — — — — — — — — — — — — — — — — — — —

How to check if the element exist?

if ($(selector).length)