Like many question I have seen the jQuery document.ready works in the web-part during editing but not after I save the page. I found this code on SO and thought I run a couple of test to see what was happening, I added a couple of alert boxes to see how jQuery was being loaded. to my surprise the script section is never called? below is how I have my setup any help would be great. I'm using SharePoint 365 2013
<script type="text/javascript" src="../master_page_items/jquery-2.2.0.min.js"></script>
<script type="text/javascript" src="../master_page_items/jquery-ui-1.11.4/jquery-ui.js"></script>
<script type="text/javascript" src="../master_page_items/picture_slider.js"></script>
<script type="text/javascript" src="https://c64.assets-yammer.com/assets/platform_embed.js"></script>
<script language="Javascript" type="text/javascript">
// Only do anything if jQuery isn't defined
if (typeof jQuery == 'undefined') {
if (typeof $ == 'function') {
// warning, global var
thisPageUsingOtherJSLibrary = true;
alert('thisPageUsingOtherJSLibrary NOT DEFINE');
}
function getScript(url, success) {
var script = document.createElement('script');
script.src = url;
var head = document.getElementsByTagName('head')[0],
done = false;
// Attach handlers for all browsers
script.onload = script.onreadystatechange = function() {
if (!done && (!this.readyState || this.readyState == 'loaded' || this.readyState == 'complete')) {
done = true;
// callback function provided as param
success();
script.onload = script.onreadystatechange = null;
head.removeChild(script);
};
};
head.appendChild(script);
};
getScript('http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js', function() {
if (typeof jQuery=='undefined') {
// Super failsafe - still somehow failed...
alert('Super failsafe - still somehow failed...');
} else {
// jQuery loaded! Make sure to use .noConflict just in case
fancyCode();
if (thisPageUsingOtherJSLibrary) {
alert('thisPageUsingOtherJSLibrary');
} else {
// Use .noConflict(), then run your jQuery Code
alert('Use .noConflict(), then run your jQuery Code');
}
}
});
} else { // jQuery was already loaded
// Run your jQuery Code
alert('Run your jQuery Code');
};
</script>