I am using getscript() to load some scripts for my image gallery. As soon as I click on the gallery, this code runs :
$(function () {
$(window).hashchange(function () {
$(document).ready(function () {
$('#nav li a').click(function () {
$('#content-wrap').load(toLoad, showNewContent);
function showNewContent() {
if ($('#content-wrap').is(':empty')) {
return false;
} else {
if (window.location.hash == "#photos") {
alert("soundswaste1");
$.getScript("galleria/galleria-1.2.8.min.js");
$.getScript("galleria/themes/classic/galleria.classic.min.js", getGalleria);
function getGalleria() {
alert("soundswaste2");
$.getScript("galleria.js");
}
}
$('#content-wrap').fadeIn(500).css("display", "block");
}
return false;
});
});
});
});
First I go to chrome console -> right click on network tab -> clear browser cache -> refresh the page -> and click on photos. I get alert "soundswaste1" and the effect doesn't run. The images just line up on the page.
Then I simply click on 'photos' again, and I get both the alerts, each of them twice. 2 questions :
Why does clearing-cache prevents all the scripts from loading the first time. Is it because they are located at different paths?
Why do I get the alerts twice the 2nd time?