0

I am attempting to try speed up my web page by "Removing render-blocking JavaScript" using this defer method:

<script type="text/javascript">
function downloadJSAtOnload() {
var element = document.createElement("script");
element.src = "js/combination.js"; // replace defer.js with your script     instead
document.body.appendChild(element);
}

if (window.addEventListener)
window.addEventListener("load", downloadJSAtOnload, false);
else if (window.attachEvent)
window.attachEvent("onload", downloadJSAtOnload);
else window.onload = downloadJSAtOnload;
</script>

I've combined all my javascript files into 1 called combinations.js but whenever I try combine this jquery library UI:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>

with combinations.js, my jquery scripts don't work.

So Google Page speed is still saying that I need "Removing render-blocking JavaScript" for this library but how?

UPDATE:

When I add the Jquery UI Library to the top of my combination.js file and test it on CHROME and IE9 it works! The problem I now have above, is when I test it on Firefox (I've got version 35). So this seems to be a firefox issue

user3364730
  • 243
  • 1
  • 5
  • 16
  • why don't you add jquery UI into `combination.js`? And if you put your scripts at the end of the body, they don't block rendering in the first place. – Evan Davis Jan 23 '15 at 00:02
  • I've tried adding the UI into combination.js (at the top of the file) and by doing so, it stops my scripts from working. "And if you put your scripts at the end of the body, they don't block rendering in the first place" ... body of where? The html page or combination.js? – user3364730 Jan 23 '15 at 00:12
  • what errors are thrown? Is jQuery loading before jQueryUI and other plugins and dependent code? – charlietfl Jan 23 '15 at 00:15
  • Please see the UPDATE in my post. To be honest, I don't know how to check for errors (Browser "Debugger"?) – user3364730 Jan 23 '15 at 00:27
  • 1
    AHHHHHHHHH!!!!! I deleted my firefox browser history and now it's all working!!! Sorry guys and thanks for your input at least (now I'm going to be sh@t out by stackoverflow). What should I put as my answer when the time comes? – user3364730 Jan 23 '15 at 00:37

1 Answers1

0

It looks like It was my history in firefox not re-loading my Jquery Library even when I did a full refresh (CRTL + F5). Strange, anyway if anyone happens to get this problem, delete all your history and load up your website up again. Amazing how such a simple solution can take up so much time.

user3364730
  • 243
  • 1
  • 5
  • 16