mCs mCs - 1 year ago 55
Javascript Question

Query GitHub Pages and JavaScript libs dont't work

I have tried to test a static website with JS libs LINK on a

GitHub Pages
However, it seems that the JS (main site carousel or photo carousel) is not working on GitHub Pages.

The same code locally and on localhost temporary apache work excelent like LINK2.

JQuery as an example:

<script type="text/javascript">
if (typeof jQuery == 'undefined') {
document.write(unescape("%3Cscript src='/javascripts/jquery.min.js' type='text/javascript'%3E%3C/script%3E"));

What seems to be the problem?


You are using mixed content. Libraries are not being loaded because their scheme is http, while GitHub Pages is using https:

Google chrome console errors

You need to change all the resources routes to match https protocols. If the resources websites do not allow you to do that, then you may want to download the libraries and upload to your page, instead of using CDNs. Links will go like this:

<script src='relative/server/folder/to/jquery.min.js' /> 

Also, you may want to read this for further information and instructions.

Another points you sould fix:

  • Your website, after loading jQuery, $ is not defined, but jQuery does. You should fix this, or use jQuery instead of $.
  • After loading your carousssel with jQuery("#mojbanner").load("assets/revslider/moj_slider.html");, assets/revslider/moj_slider.html contains more http content (instead of https). You should fix this html too.
  • Try fixing all the errors you see on the Chrome (or Firefox, or whatever explorer) debugging console.