Newb Question Not Issue
dgerding opened this issue · 3 comments
Sorry to ask but when you say:
var scrollMonitor = require("scrollmonitor"); // if you're old school you can use the scrollMonitor
// global.
What's the right way to create the scrollMonitor instance without using require?
Thanks if your able to help and thanks regardless for cool code.
As the following comment implies, in case you are not using any module bundler (e.g. webpack, parcel...) which resolves the require
s / import
s for you, you should use the globally available variable (window.scrollMonitor
I guess).
Please mind that since the latter is attached to the window
object, you don’t need to specify window.
at all. Just act as if the import was already done and reference scrollMonitor
with no worries.
One thing I forgot to mention: module bundlers inject dependencies where needed, but if you are not using any, you should always import the script you are referencing either in the <head>
or at the end of the <body>
.
Thanks Federico, that helped!