Yepnope download js twice
I am trying to load a JS file using yepnope using the below code:
yepnope({
load: '<?php echo base_url(); ?>static/js/highlight.min.js',
complete: function()
{
hljs.tabReplace = ' ';
hljs.initHighlightingOnLoad();
}
});
However, when I look in firebug to see what is loading, it shows that it is loading twice. Am I doing something wrong because I am confused?
source to share
Before posting, before posting, it should have been really more complicated for the existing answers.
I see two requests in my dev tools, why is it downloading everything twice?
Depending on your browser and your server, this can mean a couple of different things. Because of the way yepnope works, there are two requests for each file. The first request is to load the resource into the cache, and the second request is to execute it (but since it's in the cache, it should be executed immediately). Seeing two requests is pretty common as long as the second request is cached. If you notice that the second request is not cached (and your script load doubles at a time), then make sure you send the correct cache to ensure your scripts are cached. This is important for yepnope. It won't work without proper caching. We're actually making sure that our test suite is not loaded twice, so if you think we might have a bug in your browser regarding dual loading, we recommend that you run the test suite to seeif double loading test passes.
source to share