Google Analytics, jQuery Magnific Popups, .NET master page implementation - javascript

I will start with admitting that although I have been researching, reading, and trouble-shooting my issue I think I am missing something fundamental with my site. I apologize for my ignorance in advance but this is the only way to learn--by admitting you don't know what to do.
I'm running a VB.NET site which has a master page and content pages. I am still very much in development of the entire site trying to add features.
What I'd like to do:
I would like to add google analytics and jquery magnific popup. I've followed all the instructions from google and from magnific pop-up and I'm still having issues.
What I've done to try and make this work so far:
My head on masterpage:
<script src="Scripts/googleanalytics.js" type="text/javascript"></script>
<script src="Scripts/jquery-2.1.3.js" type="text/javascript"></script>
<script src="Scripts/jquery-magnific-popup.js" type="text/javascript"></script>
My footer on masterpage:
<script type="text/javascript">
$('.test-popup-link').magnificPopup({type: 'image'});
</script>
Added class to image:
<a class="test-popup-link" href="img/bigdog.jpg"><img class="centerimg" src="img/smalldog.jpg" /></a>
My issues:
Google script fails to find script. It's definitely there, it was
copy/pasted directly from google's site into a file I am calling.
jquery and magnific pop-up only load on my root pages.
"/products/product1.aspx" pages for example refuse to load scripts.
Although they load on root pages, the script does not appear to work
for the image pop up. I've followed magnific-popup's instructions word for word for "initializing in html"
Instructions for magnific-popup: http://dimsemenov.com/plugins/magnific-popup/documentation.html#mfp-build-tool
Lastly, before I tried adding the image pop-up google analytics appeared to be working as I was getting reporting on the web analytics page.
Any help would be appreciated.

Solution found via talking it out on IRC.
I restarted my local server and it worked on my root directory. Race conditions or caching causing the problem?
I needed to add "/" before "Scripts" in my head which fixed non-root script loading.
Thanks to robert on freenode for talking me through it. :D

Related

Javascript not included play framework

I'm working on a website with play framework and I have a little problem.
I am using a main.scala.html page which includes a <script src="#routes.Assets.versioned("javascripts/jquery.js")"></script>
Then to create a page I use #main("pagename") {body content here}
The problem is that when I start the webserver it doesn't include the javascript file. It does work for the CSS however: <link href="#routes.Assets.versioned("stylesheets/main.css")" rel="stylesheet">
This is showing in chrome developer tool:
The jquery.js is located in: /public/javascripts/jquery.js
Does somebody know how to fix this? Thanks
I have put the script tags inside the body now and it works. Don't know why it doesnt work when I put it in the main.

integrate Accelerated Mobile Pages in vivvo template

I am working on vivvo template. Which is completed, now I have to integrate Accelerated Mobile Pages (AMP) in it. To reference amp js file use this
<script async src="https://cdn.ampproject.org/v0.js"></script>
but this file did't included in pages. And all reference files css and js after this line didn't loaded. I followed this link to use amp
Create Your First AMP Page
What am i missing. Please help. Thanks
Well for a start you can't use any other CSS files (inline CSS only) nor Javascript.
What do you mean "this file did't included in pages"? That piece of javascript is mandatory on an AMP page (it's what makes it an AMP page).
Also have you used the #development=1 option in Google Chrome? Append that to your URL and then reload the page with Developer tools open and look at the console to see errors.
I've blogged my own experiences creating AMP pages here: https://www.tunetheweb.com/blog/implementing-accelerated-mobile-pages/ as there were a few funnies I didn't realise until I started implementing them.

How can I find the source of a <script> placed in the footer?

I would greatly appreciate it if someone could shed some insight onto a problem I'm having.
The code below is from the footer of a WordPress website I run, and as you'll notice, the second script is invalid. I have no idea where that even came from or how to fix it, and I've searched through many WordPress PHP files (footer.php, index.php, page.php, etc.) to try to find the source, but I'm not sure where it is.
So my question is this: could someone tell me how to find the source of this script? In other words, how can I find out where that second line of code even comes from? I'm not a developer, so sorry if this is a dumb question. Here's the code for you to reference:
<script defer="defer" src="http://echidnainc.com/wp-includes/js/admin-bar.min.js" type="text/javascript"></script>
<script defer="defer" src="http://echidnainc.comhttp//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.js" type="text/javascript"></script>
<script defer="defer" src="http://echidnainc.com/wp-content/plugins/easy-social-share-buttons/assets/js/easy-social-share-buttons.min.js" type="text/javascript"></script>
<script defer="defer" src="http://echidnainc.com/wp-content/plugins/easy-social-share-buttons/assets/js/essb-sticky-sidebar.js" type="text/javascript"></script>
<script defer="defer" src="http://echidnainc.com/wp-content/plugins/easy-slide-in/optin-forms-manager/js/placeholder.js" type="text/javascript"></script>
So to answer the general question I posed, to find the source of a line of code placed in the footer of a WordPress page, the first thing to try should probably be the one-by-one deactivation of plugins until the script disappears (and obviously, when the script disappears, then you know the last plugin to be deactivated was responsible). That worked for me.
And now for details on my specific situation's resolution:
A plugin, Speed Booster Pack, was causing the erroneous script:
<script defer=”defer” src=”http://echidnainc.comhttp//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.js” type=”text/javascript”></script>
Either that erroneous script or another element of the Speed Booster Pack was interfering with another plugin I recently installed. I tried tweaking some PHP files in the Speed Booster Pack, but ultimately I just deactivated the plugin in order to solve the problem.
I browsed to each of the scripts you mentioned in your post (just pasted the link into my browser to see the JavaScript source). It doesn't seem to be any of those scripts that are adding the tag to Google's hosted version of jQuery.
My suggestion, without knowing the source of the plugins you have in your wordpress, is that one of the plugins is trying to include jQuery, and has an error.
As to why the scripts are loaded at the end of the page, this is a combination of the "defer" tag, combined with a common web development trick that placing tags at the end of the page body facilitates faster load times.
If you could refer to the source code for any of the plugins I don't mind checking to see which one, if any, have the typo. You yourself could attempt to remove plugins one by one to see if one causes the script tag to disappear, and boom, culprit.
The second script is invalid, because the url in the src="..." arrtibute is invalid. I assume you wanted to use jQuery, a JavaScript libary.
To fix that replace
src="http://echidnainc.comhttp//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.js"with src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.js"
The jQuery libary hosted by Google.

javascript conflict in Joomla

Can anyone help I am getting what seems to be conflicting Javascript in a Joomla site I am making. When the following scrip is added to the site I cannot add a listing in mosets tree
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js" type="text/javascript"></script>
If i take this code out the listing works as it should in Mosets tree but the Slider and other items are effected on the home page
http://mybridespace.co.uk
I have tried no-conflict script but this doesn't seem to work well.
Any ideas would be appreciated.

Remove scripts at bottom of page added by Yahoo?

I'm using Yahoo Small Business to host my website. I use an FTP client (FileZila) to upload my files. However at the end of every page is these few lines:
</html>
<!-- text below generated by server. PLEASE REMOVE -->
<!-- Counter/Statistics data collection code -->
<script language="JavaScript" src="http://us.js2.yimg.com/us.js.yimg.com/lib/smb/js/hosting/cp/js_source/whv2_001.js"></script>
<script language="javascript">geovisit();</script>
<noscript>
<img src="http://visit.webhosting.yahoo.com/visit.gif?us1264993801" alt="setstats" border="0" width="1" height="1">
</noscript>
Everytime I remove it, it comes back. The comment says to remove it. Why the heck can't I remove this. As a side not this is the only thing keeping my site from validating as valid HTML 5.
My guess is, it is generated by Yahoo's SB engine for tracking purposes. If you were to download the file and edit, the comment stated that you remove those lines so that Yahoo engine will add it again upon upload.
PS: I really don't think Yahoo Small Business cares about HTML5 validation.
I was just fixing a Yahoo SE site for a friend and that script is a Yahoo tracker. To remove it, go into the "web hosting control panel", "site statistics", then click the options button in the top right. Remove the "statistics" option and you're good to go.
It's now Validating HTML5 - Hope this helps
That same code was causing upward of 75-second delays on all my pages starting two days ago -- it calls for a one-pixel image located at https://visit.webhosting.yahoo.com/visit.gif
(you can see the image tag in skaffman's question above -- next-to-last line) but that particular link has been broken for the past three days. The result is that every page that has an onload script will hang before it can run the script, as the Yahoo code preempts the page's onload scripts.
My solution was to call Yahoo customer service and have them disable the site statistics (which now also means that I can no longer track usage of my site via their hosting interface).
Yahoo no longer give you the option to be rid of that code snippet. We're stuck with it until they are no longer our ISP. That will be soon.

Categories

Resources