Getting 'undefined' when using inline script in combination with the script.js file #132
Replies: 1 comment 4 replies
-
Hi Luuk—Thanks for posting this, and sorry for the delay in responding! I was out sick last week. I'll need a few more details about how you're trying to use the script. But from a high level, I'd expect something like this in your import Typewriter from 'typewriter-effect/dist/core';
var app = document.getElementById('app');
window.typewriter = new Typewriter(app, {
loop: true,
delay: 75,
}); I'm assuming you're trying to put something like this in a template: window.typewriter
.pauseFor(2500)
.typeString('A simple yet powerful native javascript')
.pauseFor(300)
.deleteChars(10)
.typeString('<strong>JS</strong> plugin for a cool typewriter effect and ')
.typeString('<strong>only <span style="color: #27ae60;">5kb</span> Gzipped!</strong>')
.pauseFor(1000)
.start(); If that's the case, you'll need to have the JavaScript in the template only run after You could also put a check for the existence of There are probably other ways this could be done! Those are two off the top of my head. The fundamental problem is, as you guessed, that you need to make sure |
Beta Was this translation helpful? Give feedback.
-
Hi,
I'm using the following javascript plugin for a typewriter effect: https://github.com/tameemsafi/typewriterjs.
I've done everything as explained in the docs, but I'd like to use the typewriter.typestring.... part inline in a file. When doing this I get
Uncaught ReferenceError: typewriter is not defined
. This is due to the fact that the script.js gets added to the footer, so that means this gets loaded after the inline script. Is there a way to fix this? I need to use the script inline since I'm using ACF to get values that I'm using in the plugin.Beta Was this translation helpful? Give feedback.
All reactions