Support Forum

Please note that this forum is only available to you in read only mode. In order to contribute to this conversation you will need to renew your subscription.

Bug: homepage is being loaded as script on every page load

zentoolsIf you use Zentools please post a review at the Joomla! Extensions Directory.

Hi,

There is some wierd Javascript script loading bug. The page tries to load a javascript script wich is the homepage of the website (a html page), you can see it on your demo in the source: script src="/showcase/nov14/" type="text/javascript">/ script (I remove the < > in the script to be able to post this)

That creates 2 side-effects: a Javascript error in the console: Uncaught SyntaxError: Unexpected token <

Wich is logic because the first character of the HTML page is the < of the doctype.

The other side-effect is a big hit on performance, the page actually loads 2 times instead of 1 because it's redownloading the homepage entirely trying to load it as javascript. So instead of 900ms once, it's 900ms x 2 (900ms as example). I know that you are trying to get a great performance on this template so this fix will help a lot. It will actually reduce the time of the loading by 2 if you got every assets browser cached.

I included a screenshot to show the 2 side-effects (javascript error and hit on page load). I got the exact same problem on my version. I browser cached everything so the 2 page loads are the only ones taking more than 0 ms.

How can I remove that line script src="/showcase/nov14/" type="text/javascript" /script to solve that bug?

Thanks

EDIT: I put the wrong screenshot, here is the good one.
Attachments:
  • Pierre Eli Normandeau's Avatar
  • Pierre Eli Normandeau
  • 3 Month Basic
  • 28 posts
  • Karma: 0
Last Edit: 9 years 3 months ago by Pierre Eli Normandeau. Reason: I put the wrong screenshot, here is the good one.
The administrator has disabled public write access.
I see that you are replying every other thread but not this one. Is it possible to get some support on this? The site was supposed to be fast but it's not the case.

Thanks
  • Pierre Eli Normandeau's Avatar
  • Pierre Eli Normandeau
  • 3 Month Basic
  • 28 posts
  • Karma: 0
The administrator has disabled public write access.
My apologies I should have explained why I've not replied

Its beyond my knowledge to give an answer
Anthony is away for New Year and will look at the issues you raise

I'm sorry for the delay

Cheers
Paul
  • manh's Avatar
  • manh
  • Moderator
  • 45248 posts
  • 2106 Thanks
  • Karma: 603
The administrator has disabled public write access.
Okay thanks, I will wait for his answer.
  • Pierre Eli Normandeau's Avatar
  • Pierre Eli Normandeau
  • 3 Month Basic
  • 28 posts
  • Karma: 0
The administrator has disabled public write access.
Thanks I will get back to as soon as I can

Cheers
Paul
  • manh's Avatar
  • manh
  • Moderator
  • 45248 posts
  • 2106 Thanks
  • Karma: 603
The administrator has disabled public write access.
Hi there. I'm still away and on mobile with patchy coverage.

How are you seeing the page load twice? I didn't see that in any of my tests. I'm not ruling it out but I'm sure it's something I would have noticed.

Thanks
  • Anthony Olsen's Avatar
  • Anthony Olsen
  • LIfetime Developer - Big Bamboo
  • 23925 posts
  • 788 Thanks
  • Karma: 433
The administrator has disabled public write access.
Hi Anthony,

I included a screenshot showing the proof that the homepage is being loaded as a script everytime we load a page. It is causing a javascript error (obviously because it's trying to load html as javascript), and it is loading the homepage for nothing everytime we load a page so it's raising the server response time.

Thanks
  • Pierre Eli Normandeau's Avatar
  • Pierre Eli Normandeau
  • 3 Month Basic
  • 28 posts
  • Karma: 0
The administrator has disabled public write access.
I have a feeling the error is caused by gzip. Do you have that on?

The error that relates to html is just pointing out that the issue occurs in the rendered page. It's not an html file loading.

Check the network connection in the inspector and you will see the load times. In chrome if you click preserve log ( or something like that) the error should show twice if the page is loaded twice.
If it is then we will obviously fix that and I will get a fix for the error in the console but in fairly certain the page isn't loading twice.
  • Anthony Olsen's Avatar
  • Anthony Olsen
  • LIfetime Developer - Big Bamboo
  • 23925 posts
  • 788 Thanks
  • Karma: 433
The administrator has disabled public write access.
Anthony,

I am not sure you understand the problem properly. GZIP is off and it has nothing to do with it.

The javascript isnt appearing twice because the call causing it only happens 1 time. The homepage is being included as javascript on every page.

Did you check my screenshot? It is a chrome inspector screenshot, we clearly see that the template is trying to include the home page as a javascript script. We even see it in the html source of the template, take a look, you'll see that the homepage is included as a javascript script. This happens on every page of the template, it is always the home page that is called as javascript. The javascript error in the google chrome console is poiting to the homepage being called as javascript, the first character < of the page of (<!DOCTYPE html>), it's obviously an error because it's not javascript but HTML.

Please take some time to check my screenshot and take a look at the HTML source of your demo with chrome. You will see that the homepage is being called as javascript, I can't copy the line here because your website is preventing me from including javascript. But it's a regular script type="javascript" call, with the homepage as the src=" "

Thanks
  • Pierre Eli Normandeau's Avatar
  • Pierre Eli Normandeau
  • 3 Month Basic
  • 28 posts
  • Karma: 0
The administrator has disabled public write access.
Anthony, here is a screenshot showing the homepage being called as javascript in the HTML source.
Attachments:
  • Pierre Eli Normandeau's Avatar
  • Pierre Eli Normandeau
  • 3 Month Basic
  • 28 posts
  • Karma: 0
The administrator has disabled public write access.
From the screenshot it looks like it's one of the strip script functions not getting the whole script removed. It's not trying to include the home. I still can't see what you mean by loading the page twice. Including the base irk as a script tag won't do that.

At any rate I can't look at this underhill until Saturday evening my time - it's Friday afternoon here now. I will get a fix for the error though and I'll look further into your idea regarding the page loading twice but I really can't see how that's happening.

Anthony
  • Anthony Olsen's Avatar
  • Anthony Olsen
  • LIfetime Developer - Big Bamboo
  • 23925 posts
  • 788 Thanks
  • Karma: 433
The administrator has disabled public write access.
Hi Anthony,

The base url is the homepage. The homepage is being included as a javascript script in the head of the HTML. Of course you can include HTML as javascript, the browser doesn't know the difference, it's just code and it's trying to parse the homepage HTML as javascript, that's the reason of the javascript error and it's also the reason why the whole homepage is being loaded everytime a new page loads. You can see with Google Chrome in the network section that yes, the homepage is being loaded as Javascript for nothing, and thats the source of the JS error, Google inspector is even telling you that the Character 1, line 1: < is where the error happens, this is the first character of the homepage html doctype! Not sure what you are missing?

If you still don't understand, please tell me why the base irk like you call it is being loaded as a script in the first place? What is the reason of this include, why is it there and what does it load?

The page isnt loaded 2 times but the page we are on + the homepage is loaded, here is what is happening:

1. We load the page we are navigating (server send us the page)
2. The base irk javascript script is read by the browser, so the browser ask the server to send him the base irk (homepage) code, so the server has to threat the homepage to get the code and send it back (thats where we lose performance, couple hundreds ms), the server then send the homepage code to the browser and the code is HTML code because its the homepage
3. Browser try to parse the homepage code he just received to threat the javascript, fail on first character, first line < (opening of doctype of the homepage code) so that's the javascript error we are getting

The fix is actually pretty simple, just need to remove that javascript base url irk call from the HTML source
  • Pierre Eli Normandeau's Avatar
  • Pierre Eli Normandeau
  • 3 Month Basic
  • 28 posts
  • Karma: 0
The administrator has disabled public write access.
You talked about the stripscript failing, can you please point me out where to look in the code to prevent this javascript include? I need to fix this fast and I will look into and send you the fix when I got it.

Thanks.
  • Pierre Eli Normandeau's Avatar
  • Pierre Eli Normandeau
  • 3 Month Basic
  • 28 posts
  • Karma: 0
The administrator has disabled public write access.
Hi Pierre,

Sorry I understand the issue now.

I've attached the following file that will fix the issue:

upload to templates/rasa2/zengrid/

Thanks for your patience and apologies that it took me this time to find the issue.

Ill release this as a fix in an update when Im back from my holiday.
Attachments:
  • Anthony Olsen's Avatar
  • Anthony Olsen
  • LIfetime Developer - Big Bamboo
  • 23925 posts
  • 788 Thanks
  • Karma: 433
The administrator has disabled public write access.
Hi Anthony,

No problem and thanks for looking and fixing the issue even if you're in vacation right now!

I am having trouble to download the .zip thought, seems like the file is broken. Can you please repost it?

Thanks.
  • Pierre Eli Normandeau's Avatar
  • Pierre Eli Normandeau
  • 3 Month Basic
  • 28 posts
  • Karma: 0
The administrator has disabled public write access.
Here is the full zip of the template.
Attachments:
  • Anthony Olsen's Avatar
  • Anthony Olsen
  • LIfetime Developer - Big Bamboo
  • 23925 posts
  • 788 Thanks
  • Karma: 433
The administrator has disabled public write access.
We posted at same time. Thanks
  • Pierre Eli Normandeau's Avatar
  • Pierre Eli Normandeau
  • 3 Month Basic
  • 28 posts
  • Karma: 0
Last Edit: 9 years 3 months ago by Pierre Eli Normandeau.
The administrator has disabled public write access.
Thanks Anthony,

It's working good now, I can see a big improvement in page load since the "javascript homepage" wasn't cached and browser cached neither.

I wouldnt be suprised it raise the index in the performance tests.
  • Pierre Eli Normandeau's Avatar
  • Pierre Eli Normandeau
  • 3 Month Basic
  • 28 posts
  • Karma: 0
The administrator has disabled public write access.
Thanks for the update

Cheers
Paul
  • manh's Avatar
  • manh
  • Moderator
  • 45248 posts
  • 2106 Thanks
  • Karma: 603
The administrator has disabled public write access.

zentoolsIf you use Zentools please post a review at the Joomla! Extensions Directory.

Happy Campers