When not miniifying the scripts window.onload
does work as expected.
But when I do minified my scripts using Uglify-js Folder it does not.
If I write the following and minify it :
window.onload = function() {
// My code
console.log( "HELLO TO YOU" );
};
It does not work in the browser.
But I f I write the following:
jQuery(document).ready(function() {
// My code
console.log( "HELLO TO YOU" );
});
It works fine!
Even just the console.log() alone does not print any thing using window.onload
when minified.
Any ideas??
Here is the output:
window.onload = function() {
let e = document.querySelector("#main-header")
, t = e.offsetHeight
, o = document.querySelector("#et-main-area")
, n = document.querySelector("#wpadminbar");
o.style.marginTop = t + "px",
e.style.top = n ? n.offsetHeight + "px" : "0px"
}
,
jQuery(document).ready((function() {
let e = document.querySelector("#main-header")
, t = e.offsetHeight
, o = document.querySelector("#et-main-area")
, n = document.querySelector("#wpadminbar");
o.style.marginTop = t + "px",
e.style.top = n ? n.offsetHeight + "px" : "0px",
console.log("HELLO")
}