Try to not use JQuery for that :
This will ensure that JQuery is loaded before using it.
window.addEventListener("load", function(event) {
$('#preloader').delay(400).fadeOut(500);
// Do what you want, the window is entirely loaded and ready to use.
});
The load event is fired when the whole page has loaded, including all dependent resources such as stylesheets images. This is in contrast to DOMContentLoaded, which is fired as soon as the page DOM has been loaded, without waiting for resources finish loading.
Mozilla documentation: load event
Edit : According to the question to not confusing window.loaded and jquery.load
First, change jquery.slim to jquery like previous response
Second, use native event handler for best practice (in my opinion) with modern browsers.
// To be sure $ is defined
// Window loaded event
window.addEventListener("load", function(event) {
// Now $ or JQuery is completly available
// Now using JQuery.load() should be defined
$('#test').load('doesntmatter');
// Do what you want, the window is entirely loaded and ready to use.
});
alert('test');
does THAT work? If not your script files aren't loading for JS, but => isn't valid syntax so that's also an error. – Photoelectrotype