Javascript not loading in Safari - javascript

Im working on a site that I'm launching tonight and for the life of me cannot figure out why my scripts are not working in Safari. All is fine in Chrome but it seems like the scripts arent even loading for the site in safari. Im loading the scrips using wordpress's wp_enqueue_script() function and this is how the scripts are rendering in the source
<script type='text/javascript' src='http://52.26.145.136/FitnessFifteen/wordpress/wp-includes/js/jquery/jquery.js?ver=1.12.4'></script>
<script type='text/javascript' src='http://52.26.145.136/FitnessFifteen/wordpress/wp-includes/js/jquery/jquery-migrate.min.js?ver=1.4.1'></script>
<script type='text/javascript' src='http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js?ver=4.5.3'></script>
<script type='text/javascript' src='http://52.26.145.136/FitnessFifteen/wordpress/wp-content/themes/fitnessfifteen/js/jquery.easing.min.js?ver=4.5.3'></script>
<script type='text/javascript' src='http://52.26.145.136/FitnessFifteen/wordpress/wp-content/themes/fitnessfifteen/js/scrolling-nav.js?ver=4.5.3'></script>
<script type='text/javascript' src='http://52.26.145.136/FitnessFifteen/wordpress/wp-content/themes/fitnessfifteen/js/responsiveScript.js?ver=4.5.3'></script>
<script type='text/javascript' src='http://52.26.145.136/FitnessFifteen/wordpress/wp-content/themes/fitnessfifteen/js/signup-script.js?ver=4.5.3'></script>
<script type='text/javascript' src='http://52.26.145.136/FitnessFifteen/wordpress/wp-content/themes/fitnessfifteen/js/slide-script.js?ver=4.5.3'></script>
<script type='text/javascript' src='http://52.26.145.136/FitnessFifteen/wordpress/wp-content/themes/fitnessfifteen/js/clients-script.js?ver=4.5.3'></script>

Related

After adding SSL with cloudfare, the JS does not work and this error occurs in Network,

So i added SSL with cloudfare to my site but all the JS no longer works. I have set all links in the source code to https but that didnt work.
The server is running apache2 on debian 7
I get this error however, maybe someone will understand it?
Error Pic 1,
Error Pic 2
<script type="text/javascript" src="/template/js/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="/template/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/template/js/socket.io-1.4.5.js"></script>
<script type="text/javascript" src="/template/js/jcanvas.min.js"></script>
<script type="text/javascript" src="/template/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="/template/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/template/js/bootbox.min.js"></script>
<script type="text/javascript" src="/template/js/dataTables.bootstrap.js"></script>
<script type="text/javascript" src="/template/js/tinysort.js"></script>
<script type="text/javascript" src="/template/js/expanding.js"></script>
<script type="text/javascript" src="/template/js/notify.js"></script>
<script type="text/javascript" src="/template/js/plot.js?v=<?=time()?>"></script>
<script type="text/javascript" type="text/javascript" src="/template/js/graph.js?v=<?=time()?>"></script>
<script type="text/javascript" src="/template/js/settings.js"></script>
<script type="text/javascript" src="/template/js/app.js?v=<?=time()?>"></script>
If you can provide littel more detail. Path of one of your JS(not loading) may be.

Js scripts break from footer

Google speed optimization tests recommend that I optimize my page by moving all non-essencial css and js to my footers. The css was easy, move anything relating to click effects or hover effects to the footer.
However the javascripts, I am finding cannot be moved. I am using a bootstrap template that is a bit dated. There are 28 scripts that all load locally, mostly various jquery libraries.
I have gone through about 5 pages on the site and one by one tried to move each of the javascripts to the footer. Every single one causes some sort of js error or another on my site.
Now, the part that really baffles me is, I have viewed the source to be sure, and there is not a single js file running anywhere else on the pages that I have tried this on.
I have also tried moving all the scripts to the footer at once. No matter what, if I remove them from the header - I get js errors and things start failing... accordion menu's, object placement, everything...
So my question is, how is it that my site breaks when I put my js files in the footer even when there is no other javascript on the page? What is it I do not understand because clearly I am not understanding something.
(by footer I am talking about code just before the close body tag, not in a footer tag or div designed for the footer)
the scripts from my header
<link rel="icon" type="image/ico" href="favicon.ico"/>
<script type='text/javascript' src='/js/jquery.js'></script>
<script type='text/javascript' src='/js/jquery-ui.min.js'></script>
<script type='text/javascript' src='/js/plugins/bootstrap.min.js'></script>
<script type='text/javascript' src='/js/plugins/fullcalendar/fullcalendar.min.js'></script>
<script type='text/javascript' src='/js/plugins/jquery/jquery.mousewheel.min.js'></script>
<script type='text/javascript' src='/js/plugins/cookie/jquery.cookies.2.2.0.min.js'></script>
<script type='text/javascript' src='/js/plugins/charts/excanvas.min.js'></script>
<script type='text/javascript' src='/js/plugins/charts/jquery.flot.js'></script>
<script type='text/javascript' src='/js/plugins/charts/jquery.flot.stack.js'></script>
<script type='text/javascript' src='/js/plugins/charts/jquery.flot.pie.js'></script>
<script type='text/javascript' src='/js/plugins/charts/jquery.flot.resize.js'></script>
<script type='text/javascript' src='/js/plugins/sparklines/jquery.sparkline.min.js'></script>
<script type='text/javascript' src='/js/plugins/select2/select2.min.js'></script>
<script type='text/javascript' src='/js/plugins/uniform/uniform.js'></script>
<script type='text/javascript' src='/js/plugins/maskedinput/jquery.maskedinput-1.3.min.js'></script>
<script type='text/javascript' src='/js/plugins/validation/languages/jquery.validationEngine-en.js' charset='utf-8'></script>
<script type='text/javascript' src='/js/plugins/validation/jquery.validationEngine.js' charset='utf-8'></script>
<script type='text/javascript' src='/js/plugins/mcustomscrollbar/jquery.mCustomScrollbar.min.js'></script>
<script type='text/javascript' src='/js/plugins/animatedprogressbar/animated_progressbar.js'></script>
<script type='text/javascript' src='http://cdnjs.cloudflare.com/ajax/libs/qtip2/3.0.3/jquery.qtip.min.js'></script>
<script type='text/javascript' src='/js/plugins/cleditor/jquery.cleditor.js'></script>
<script type='text/javascript' src='/js/plugins/dataTables/jquery.dataTables.min.js'></script>
<script type='text/javascript' src='/js/plugins/fancybox/jquery.fancybox.pack.js'></script>
<script type='text/javascript' src='/js/cookies.js'></script>
<script type='text/javascript' src='/js/actions.js'></script>
<script type='text/javascript' src='/js/charts.js'></script>
<script type='text/javascript' src='/js/plugins.js'></script>
<script type='text/javascript' src='/js/mail.js'></script>
No other scripts exist on the page. If i put them in the exact same order in my footer the site breaks....
Any code that you put inside the webpage must run on an event(callback), typically onload. The scripts. You may to load them in this order.
Library/Framework
Libraries that depends on Library
Your library
Your external scripts.

How can I make my JS script calls in Magento appear on one line?

I am doing various modifications to my NGINX Magento server and part of this is to do front end optimisations
I am currently using a CDN plugin to host my JS but Magento always calls JS lines (huge massive calls to JS libariries which looks ugly in the code view) that I want to combine to one line.
I know you can use Admin > Developer to merge JS files but I dont want to do this. I want to make this:
<script type="text/javascript" src="http://dz36xlwnpud7z.cloudfront.net/cdn/210393/js/prototype/validation.js"></script>
<script type="text/javascript" src="http://dz36xlwnpud7z.cloudfront.net/cdn/210393/js/scriptaculous/builder.js"></script>
<script type="text/javascript" src="http://dz36xlwnpud7z.cloudfront.net/cdn/210393/js/scriptaculous/effects.js"></script>
<script type="text/javascript" src="http://dz36xlwnpud7z.cloudfront.net/cdn/210393/js/scriptaculous/dragdrop.js"></script>
<script type="text/javascript" src="http://dz36xlwnpud7z.cloudfront.net/cdn/210393/js/scriptaculous/controls.js"></script>
<script type="text/javascript" src="http://dz36xlwnpud7z.cloudfront.net/cdn/210393/js/scriptaculous/slider.js"></script>
<script type="text/javascript" src="http://dz36xlwnpud7z.cloudfront.net/cdn/210393/js/varien/js.js"></script>
<script type="text/javascript" src="http://dz36xlwnpud7z.cloudfront.net/cdn/210393/js/varien/form.js"></script>
<script type="text/javascript" src="http://dz36xlwnpud7z.cloudfront.net/cdn/210393/js/mage/translate.js"></script>
<script type="text/javascript" src="http://dz36xlwnpud7z.cloudfront.net/cdn/210393/js/mage/cookies.js"></script>
<script type="text/javascript" src="http://dz36xlwnpud7z.cloudfront.net/cdn/210393/js/varien/product.js"></script>
<script type="text/javascript" src="http://dz36xlwnpud7z.cloudfront.net/cdn/210393/js/varien/configurable.js"></script>
<script type="text/javascript" src="http://dz36xlwnpud7z.cloudfront.net/cdn/210393/js/calendar/calendar.js"></script>
<script type="text/javascript" src="http://dz36xlwnpud7z.cloudfront.net/cdn/210393/js/calendar/calendar-setup.js"></script>
Change to
<script type="text/javascript" src="http://dz36xlwnpud7z.cloudfront.net/cdn/210393/js/prototype/validation.js"></script><script type="text/javascript" src="http://dz36xlwnpud7z.cloudfront.net/cdn/210393/js/scriptaculous/builder.js"></script><script type="text/javascript" src="http://dz36xlwnpud7z.cloudfront.net/cdn/210393/js/scriptaculous/effects.js"></script><script type="text/javascript" src="http://dz36xlwnpud7z.cloudfront.net/cdn/210393/js/scriptaculous/dragdrop.js"></script><script type="text/javascript" src="http://dz36xlwnpud7z.cloudfront.net/cdn/210393/js/scriptaculous/controls.js"></script><script type="text/javascript" src="http://dz36xlwnpud7z.cloudfront.net/cdn/210393/js/scriptaculous/slider.js"></script><script type="text/javascript" src="http://dz36xlwnpud7z.cloudfront.net/cdn/210393/js/varien/js.js"></script><script type="text/javascript" src="http://dz36xlwnpud7z.cloudfront.net/cdn/210393/js/varien/form.js"></script><script type="text/javascript" src="http://dz36xlwnpud7z.cloudfront.net/cdn/210393/js/mage/translate.js"></script><script type="text/javascript" src="http://dz36xlwnpud7z.cloudfront.net/cdn/210393/js/mage/cookies.js"></script><script type="text/javascript" src="http://dz36xlwnpud7z.cloudfront.net/cdn/210393/js/varien/product.js"></script><script type="text/javascript" src="http://dz36xlwnpud7z.cloudfront.net/cdn/210393/js/varien/configurable.js"></script><script type="text/javascript" src="http://dz36xlwnpud7z.cloudfront.net/cdn/210393/js/calendar/calendar.js"></script><script type="text/javascript" src="http://dz36xlwnpud7z.cloudfront.net/cdn/210393/js/calendar/calendar-setup.js"></script>
I think is what you're looking for. I tested this with Magento 1.9.2.1.
In this file Mage_Page_Block_Html_Head, function getCssJsHtml() on line 210 character 112-119 you'll find this . "\n". Remove that from the function and your JS files will be rendered in one line as you requested.
Keep in mind not to modify core files but to extend the class and override only this function to maintain rest of functionality.

What is the correct sequence of including jquery files?

Today i wanted to add datepicker() to my page.So I downloaded jqueryui and added then in the sequence below.
<script type="text/javascript" src="js/jquery.js"></script>
<script src="js/superfish.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/retina.min.js"></script>
<script src="assets/validate.js"></script>
<script src="js/jquery.placeholder.js"></script>
<script src="js/functions.js"></script>
<script src="js/wizard_func.js"></script>
<script src="check_radio/jquery.icheck.js"></script>
<script type="text/javascript" src="js/navi_artstyle.js"></script>
<script type="text/javascript" src="js/jquery-ui.js"></script>
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script type="text/javascript" src="js/mapmarker.jquery.js"></script>
<script type="text/javascript" src="js/mapmarker_func.jquery.js"></script>
It didn't work. It took me whole day to figure out what is wrong. it was the SEQUENCE of js files included!!! To work my code i had to include them like bellow.("jquery.js" position had to change)
<script src="js/superfish.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/retina.min.js"></script>
<script src="assets/validate.js"></script>
<script src="js/jquery.placeholder.js"></script>
<script src="js/functions.js"></script>
<script src="js/wizard_func.js"></script>
<script src="check_radio/jquery.icheck.js"></script>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/navi_artstyle.js"></script>
<script type="text/javascript" src="js/jquery-ui.js"></script>
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script type="text/javascript" src="js/mapmarker.jquery.js"></script>
<script type="text/javascript" src="js/mapmarker_func.jquery.js"></script>
Can some one explain this please. Please give me a Source so I wont make this mistake again.
Normal jQuery (core)
jQuery migrate if you have
jQuery UI
jQuery mobile
Scripts that need jQuery / scripts that are jQuery plugins
Other scripts like bootstrap
You own scripts depending which is needed first
First you have to include normal jQuery library.After that You have to include other jquery library like jquery ui and jquery mobile and all finally you have to include your own javascript files.
As mentioned in comments you have to mention the scripts in the order you use that.
Simply anything used Jquery will goes after jQuery, anything that depends on jQuery UI goes after jQuery UI etc.

jQuery Mobile + Cordova random errors on startup, stuck on a grey circle in the middle

I have a jQuery Mobila app wrapped with Cordova that I test on my Android device. It is fine when I launch it normally, but when I use a web intent (https://github.com/Initsogar/cordova-webintent) to launch it, the console debug shows random errors coming from the jQuery Mobile js file:
D/CordovaLog(24140): file:///android_asset/www/jquery/jquery.mobile-1.4.0.min.js: Line 7661 : Uncaught TypeError: Object # has no method 'addClass'
D/CordovaLog(22727): file:///android_asset/www/jquery/jquery.mobile-1.4.0.min.js: Line 10116 : Uncaught TypeError: Object # has no method 'each'
I am aware that these bugs are properly caused by the code I am trying to render on startup, and I'm guessing that the js files I include in the tags in index.html might be in the wrong order. Here is my current setup:
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/index.js"></script>
<script src="jquery/jquery-1.9.1.min.js"></script>
<script src="jquery/jquery-ui.min.js"></script>
<script src="jquery/jquery.ui.touch-punch.min.js"></script>
<script src="jquery/jquery.mjs.nestedSortable.js"></script>
<script src="js/json2.js"></script>
<script src="js/jstorage.js"></script>
<script src="jquery/jquery.mobile-1.4.0.min.js"></script>
<script type="text/javascript" src="js/app.js"></script>
<script type="text/javascript">
app.initialize();
</script>
I have also tried putting jquery.mobile-1.4.0.min.js under jquery-1.9.1.min.js, but similar things have happened.
Afterwards, I re-ordered them into this:
<script src="jquery/jquery-1.9.1.min.js"></script>
<script src="jquery/jquery.mobile-1.4.0.min.js"></script>
<script src="jquery/jquery-ui.min.js"></script>
<script src="jquery/jquery.ui.touch-punch.min.js"></script>
<script src="jquery/jquery.mjs.nestedSortable.js"></script>
<script src="js/json2.js"></script>
<script src="js/jstorage.js"></script>
<script type="text/javascript" src="js/index.js"></script>
<script type="text/javascript">
app.initialize();
</script>
<script type="text/javascript" src="js/app.js"></script>
And it seemed to work fine for a while or so, but am still seeing jQuery Mobile bugs here and there.

Categories