1
votes

This is my site: http://vani.valse.com.my/pixel

I tested in https://developers.google.com/speed/pagespeed/insights.

It asks to remove render blocking js file which is "js/jquery-1.7.1.min.js".

But I don't have this file anywhere in my site and all js files are compressed and placed at the footer. I even defer the page from loading but nothing works. Below is my defer code:

<script type="text/javascript">
function downloadJSAtOnload() {
var element = document.createElement("script");
element.src = "js/jquery-1.7.1.min.js";
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>

Can anyone advise why does the error shown even when the file is nowhere to be found?Many thanks.

HTML (index.php)

<!doctype html>
<html class="no-js" lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>Pixel Marketing - Home</title>

   <link rel="stylesheet" href="css/foundation.min.css">

  </head>
  <body id="home">
      <div class="row collapse">
         <div class="menu">
          <?php
          include('inc/menu.php');
          ?>
         </div>
      </div>

<!--content here-->

<script src="js/foundation.min.js"></script>

    <script>
      $(document).foundation();
    </script>

  </body>
</html>
2
Maybe you had one and Google still has it in some index and insights is not refreshed yet? - Justinas
No, it's been refreshed many times - samantha

2 Answers

0
votes

It seems path not provided correctly in

element.src = "js/jquery-1.7.1.min.js";

Either you write the path correctly

element.src = "full-path-to-jquery/jquery-1.7.1.min.js";

you can pull it from CDN

element.src = "https://code.jquery.com/jquery-1.7.1.min.js";
0
votes

It's best practice to include all the scripts at the end of the page, just right before closing the body tag. This is because when the browser finds a script tag, it downloads and executes it before continuing reading the page, hence "blocking" the page from loading.

You are actually including jquery near the top of the page:

<script src="js/jquery-1.7.1.min.js" type="text/javascript"></script>

And it does give an error in the console when loading the page because yes, you don't have that file. Remove it and the script right after it if you don't need it, and you should be fine.