WOW
WOW copied to clipboard
WOW not defined using npm package.
I did this:
npm install wowjs
and required it:
import WOW from 'wowjs
and tried to use it:
let wow = new WOW({
boxClass: 'wow',
animateClass: 'animated',
offset: 0,
live: true
});
But I got Uncaught ReferenceError: WOW is not defined
at console.
@jasonlam0619 run:
npm install wow.js
Then use:
import WOW from 'wow.js'
const wow = new WOW({
boxClass: 'wow',
animateClass: 'animated',
offset: 0,
live: true
});
Hi grain I used wow.js instead of wowjs, because it is not working with import ... from 'wowjs'
and then tried the code you have provided.
when I run in my html
<h1 class="nomargin size-50 weight-300 wow rollIn" data-wow-delay="0.5s"> blah blah </h1> <p class="lead font-lato size-30 wow fadeInUp" data-wow-delay="0.7s"> blah blah </p>
the output is it has no animate, see the screenshot:

@graingert unfortunately, the code you mentioned does not work. Something changed?
@graingert i have tried this code, but did not worked :/
any luck here?
@jsantana90 i totally give up
Same issue here...
Same issue. Surely rather important as most developers are using NPM dependencies these days?
same issue here, anyone found any solution?
Not sure if this helps, but I got it to work using require
and adding it to window
.
bootstrap.js
const WOW = require('wowjs');
window.wow = new WOW.WOW({
live: false
});
whatever.js
window.wow.init();
new WOW.WOW().init();
in your HTML file works instead of having to place it in your app.js
to compile.
This didn't work either. I used new WOW.WOW().init()
but it still doesn't work. I can see in the rendered html that the animated class is indeed being added, but the animation doesn't run.
@adammoisa Did you import WOW in anywhere of your scripts?
I'm getting the same problem, it used to work fine with this line in the controller: new WOW().init(); and importing the script in the index.html, now I get the same error and it just won't work at all
@Ruchern yes of course. As I said it adds the animated class to the HTML which I think implies the package is 'working' to some degree...
@adammoisa I'm sorry. I did not mean that.
Do you have window.WOW = require('wowjs')
?
Try either window.WOW
or window.WOW()
I cannot remember which one I tried before. Ever since moving to UIKit, I took WOW out.
the module exports an object, the WOW constructor function is inside the returned object.
const WOW = require('wowjs').WOW
window.WOW = require('wowjs').WOW worked for me
import { WOW } from 'wowjs'
window.WOW = WOW
Perhaps this might work too.
With require
const {WOW} = require('wowjs');
To Leverage Undefined Values make sure that your DOMm is ready and likely when a dependent variable is not defined. When the page is loaded and ready, and likely when a dependent variable is already defined.
For this use $(document).ready(function() { if ($.fn.init) { new WOW().init(); } });
window.WOW = require('wowjs').WOW worked for me
This works like a charm
window.WOW = require('wowjs').WOW worked for me
Thanks bro this work for me
Not sure if this helps, but I got it to work using
require
and adding it towindow
.bootstrap.js
const WOW = require('wowjs'); window.wow = new WOW.WOW({ live: false });
whatever.js
window.wow.init();
Thanks bro this work for me
window.WOW = require('wowjs').WOW;
function wowAnimation() {
new WOW({
boxClass: 'wow',
animateClass: 'animated',
offset: 0,
mobile: true
}).init();
}
wowAnimation();
React + Next js + typescript Works fine:
useEffect(() => {
const WOW = require("wowjs/dist/wow.js");
if (typeof window !== "undefined") {
(window as any).WOW = WOW;
}
new WOW.WOW().init();
}, []);
Hello,我是林昕,我已收到来信~
Try this, It works for me
// import wowjs if window is not undefined
const isServer = typeof window === "undefined";
const WOW = !isServer ? require("wowjs") : null;
// then write this code in the function
useEffect(() => {
new WOW.WOW().init();
}, []);
I hope this is useful ; )
it works for me : )
- "@sveltejs/kit": "1.15.2",
- "wow.js": "^1.2.2" (not wowjs)
npm i --save wow.js
import { onMount } from 'svelte'
onMount(async () => {
import('wow.js').then((WOW) => {
new WOW.default().init()
})
})
or
onMount(async () => {
const wow = await import('wow.js')
new wow.default().init()
})
https://github.com/matthieua/WOW/issues/252#issuecomment-1517949732 Harepo how does it work for you with sveltekit? I have it implemented but none of the animations work. Did you do have to do some extra work to make it work?