thybag / PJAX-Standalone

A standalone implementation of Pushstate AJAX, for non-jquery webpages.
203 stars 42 forks source link

don't load non-html (such as .pdf files) #18

Closed aktau closed 10 years ago

aktau commented 10 years ago

First off: pjax-standalone does wonders for my pagespeed, it's a good as local now, which is completely awesone!

One small thing though, on my homepage I link to a PDF (my résumé), and since it is served from the same domain, pjax-standalone tries to load it as partial content. I'm going to try to hack my way around it for now but it would be cool to "exclude" it somehow.

P.S.: my nanoc-generated site doesn't like the ?/& tricks so I just removed it and load the plain URLs. I serve locally via nginx, my remote site is via github, I don't suppose they do it differently.

aktau commented 10 years ago

Here's the hotfix I'm using now, by the way (to be added to the internal.attach() method):

        var exclude = {'pdf': true},
            ext = node.pathname.split('.').pop();
        if (ext in exclude) {
            return true;
        }

It could probably be made a bit more robust, as this would also ignore a totally valid link like /some/path/to/pdf or just /pdf.

thybag commented 10 years ago

Hello,

I've just pushed a fix to develop which should hopefully fix this issue also. My fix is generally along the same lines as your's although I've added a few other excluded types (images/zip files etc)

https://github.com/thybag/PJAX-Standalone/tree/develop

aktau commented 10 years ago

looks good from a cursory glance!

thybag commented 10 years ago

Fix rolled to master