Read the statement by Michael Teeuw here.
What is the difference between require() and getScripts()?
-
I’ve been trying to implement the jquery dependent package (
Tabulator) on my mirror. What it does is, convert JSON data into a nice dynamic HTML table.In the working HTML version, I just the
scripttag, to include everything, but in a Node MMM, we can either userequire("blablah")in thenode_helper.jsfile, or usegetScripts("blablah.js")in theMMM-MyModule.jsfile.- What is the difference?
- When to use what?
Right now I’m using the 2nd option, and it loads, but the table is never shown… I’m thinking I’m missing something.
-
require()is for when you mean “I’m going to use this code somewhere else in this script I am writing right now” — i.e. somewhere on the server-side.getScripts()is for when you mean “my client-facing/browser code will need this loaded to perform some operation” — i.e. somewhere on the client-side.(As always, this is what I understand and hope someone will correct me if I’m wrong.)
-
@ninjabreadman Aah! Finally. Thank you. That is the most sensible explanation I’ve seen.
(If you’re a moderator, please mark this as closed/solved.) -
Well you really shouldn’t mark this as closed or solved because I’m sure others will have questions too :)
It’s a GREAT explanation… and it’s also a GREAT question!!! I’m sure others have wondered and I know people don’t usually ask for fear they’ll look ‘not smart’…but NO question is a dumb question!!
The worst question in history? The one that never got asked! :)
-
@cowboysdude said in What is the difference between require() and getScripts()?:
I know people don’t usually ask for fear they’ll look ‘not smart’
I don’t have this problem. ;-)
-
@Mykle1 said in What is the difference between require() and getScripts()?:
@cowboysdude said in What is the difference between require() and getScripts()?:
I know people don’t usually ask for fear they’ll look ‘not smart’
I don’t have this problem. ;-)
Which one? Asking or not being smart LOL
-
Both? ;-)
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login