0

Trying to load jQuery inside a js file and when I use include I get the error

Uncaught ReferenceError: include is not defined

This is the code I have

include('https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js');

(function (window) {
  "use strict";

  var config = {
    urlPrefix: "",
    visitsUrl: "/ahoy/visits",
    eventsUrl: "/ahoy/events",
    cookieDomain: null,
    page: null,
    platform: "Web",
    useBeacon: false,
    startOnReady: true
  };

  var ahoy = window.ahoy || window.Ahoy || {};

  ahoy.configure = function (options) {
    for (var key in options) {
      if (options.hasOwnProperty(key)) {
        config[key] = options[key];
      }
    }
  };
.......

Is there a different way to load the jQuery?

Kieran Headley
  • 417
  • 1
  • 5
  • 17
  • `var jsCode = document.createElement('script'); jsCode.setAttribute('src', '//ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js'); jsCode.onload = functiontoexecutewhenitisdoneloading; document.body.appendChild(jsCode); function functiontoexecutewhenitisdoneloading() { $('body').css({'background-color':'red'}); }` – Tschallacka Oct 05 '16 at 16:10
  • Possible duplicate of [Load jQuery with Javascript and use jQuery](http://stackoverflow.com/questions/10113366/load-jquery-with-javascript-and-use-jquery) – showdev Oct 05 '16 at 16:11

0 Answers0