jqueryjquery-waypoints

Waypoints.js waypoint is not a function


I'm getting the console error:

Uncaught TypeError: $(...).waypoint is not a function

FYI: It is a Blogger template, which uses XML.

I have included the files like so (only these two .js files):

<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js'/>
<script src='https://cdnjs.cloudflare.com/ajax/libs/waypoints/4.0.1/noframework.waypoints.min.js'/>

My jQuery (longer scripts removed for clarity):

<script>
  // <![CDATA[
    $.noConflict();
    jQuery( document ).ready(function( $ ) {
      <!-- LET'S ADD SPAN ELEMENT TO WIDGET HEADINGS SO WE CAN DO ACCESSIBILITY & INCLUSIVE DESIGN -->
      $('.widget > .title').each(function() { $(this).wrapInner('<span />'); });
      <!-- LET'S ADD A CLASS TO THE MAIN MENU WHEN SCROLLING DOWN PAST THE MAIN HEADER -->
      $("#main-header").waypoint(function() { $('#main-menu').addClass('hide'); }, { offset: '100%' });
      <!-- LET'S MAKE THE PAGE LOADER GO AWAY WHEN PAGE IS LOADED  -->
      $('#page-loading-cover').delay(1500).addClass('page-loaded');
    });
  // ]]>
</script>

Why is it not working, and how do I fix it?


Solution

  • You added the stand-alone library ( — notice the noframework part), not the jQuery plugin (). See this CDN list and pick https://cdnjs.cloudflare.com/ajax/libs/waypoints/4.0.1/jquery.waypoints.min.js, i.e. include

    <script src='https://cdnjs.cloudflare.com/ajax/libs/waypoints/4.0.1/jquery.waypoints.min.js'/>
    

    instead of

    <script src='https://cdnjs.cloudflare.com/ajax/libs/waypoints/4.0.1/noframework.waypoints.min.js'/>