Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialMatt Van Dyck
2,033 PointsLazyLoad Javascript
Hi There. I am using http://justgage.com/ to load some circle charts into my site.
I would like to create a visually appealing effect so that when the user scrolls to that part of my site where the graphs are, the graphs load for them so that they can see it. How can this be achieved? Loading JavaScript on scroll?
Matt Van Dyck
2,033 PointsMatt Van Dyck
2,033 PointsThank you for your reply! Do you have any idea how to implement this with a script? I only see how to load those text popups with waypoints? How can I achieve this with loading a script say 200px from the top?
Jeremy Germenis
29,854 PointsJeremy Germenis
29,854 PointsIn the given example on the home page:
You would just replace the alert call with a function call. Place your script code in a function and load it when the page loads.
Matt Van Dyck
2,033 PointsMatt Van Dyck
2,033 PointsThanks for your response!
Unfortunately, I still cannot get my script to load.
I get errors in my browser when inspecting element in chrome saying :
Uncaught TypeError: undefined is not a function waypoints.min.js:8
Uncaught ReferenceError: $ is not defined index.php:6
Jeremy Germenis
29,854 PointsJeremy Germenis
29,854 Pointsremove the line window.onload = function(){ since you are not loading the function when the window loads, you may also need to remove the code var g1 = new