SlexAxton / yepnope.js

A Script Loader For Your Conditional Builds
http://yepnopejs.com/
BSD 3-Clause "New" or "Revised" License
2.51k stars 323 forks source link

does yepnope inject files twice (image/webp header)? #191

Closed zigotica closed 10 years ago

zigotica commented 11 years ago

hi,

i think that yepnope injects files twice, one as an image and one as a script, at least that's what inspector says. you can reproduce the issue by going to http://yepnopejs.com/ for instance and checking network for fles such as jquery, jsbeautify, etc. first injections come with Accept:image/webp,/;q=0.8 and later with Accept: /

Am i missing something? thanx

zigotica commented 11 years ago

ok, i was searching the whole internet and issues while the info is at your homepage: http://yepnopejs.com/#twice

the question remains the same. even for your own site, there are two requests per injection in chrome. no cache at all. no 304 status, all 200. apparently firefox manages cache correctly.

is there a way to ensure i can setup this correctly in my server? what does "sending the correct cache headers" imply?

thanx

tdakhla commented 10 years ago

I just started using yepnope for a website and noticed this behavior in Chrome as well. It looks like even yepnope's website requests every asset twice, although I'm not entirely sure why. Here's what I've noticed:

Bottom line: Chrome seems to treat img and script requests differently if they occur before the onload event, even if they're the exact same URL.

zigotica commented 10 years ago

hi @tdakhla I finally ended up using modernizr test + a simple async loader, something like:

injectJS : function(src, body){
        var script = document.createElement('script');
            script.src = src;
        if(body) document.body.appendChild(script);
        else  document.getElementsByTagName("head")[0].appendChild(script);
    }