0

Why do I this error below, for this node module?

Uncaught TypeError: (0 , _docready2.default) is not a function
    at Object.1.docready (bundle.min.js:32)

My main file:

import docReady from 'docready';

docReady(function() {
    console.log("DOM is ready. Let's party");
});
laukok
  • 47,545
  • 146
  • 388
  • 689
  • 1
    The docReady script you're referencing (that I wrote) is not in an ES6 module and does not export anything. It's just a direct script that you can use in a ` – jfriend00 Aug 04 '17 at 08:41
  • @jfriend00 got it. thank you! :-) – laukok Aug 04 '17 at 08:42
  • 1
    It could be put into an ES6 module with only a few lines of code if you wanted. – jfriend00 Aug 04 '17 at 08:43
  • @jfriend00 that would be wonderful! can you provide the code and update the npm? – laukok Aug 04 '17 at 08:43
  • 1
    I'm not ready to make the Github repository ES6 only so I don't think I'll change that right now. The main point of this code is to work with a wide variety of browsers (including older browsers). You could modify your own version for your own use. If you knew you had an ES6-capable browser, most of what's in that function is not needed. – jfriend00 Aug 04 '17 at 08:46
  • @jfriend00 that's ok. i will do that myself. thanks! :-) – laukok Aug 04 '17 at 08:47

1 Answers1

1

The docReady script you're referencing (that I wrote) is not in an ES6 module and does not export anything. It's just a direct script that you can use in a <script> tag and it defines a single global function name docReady.

It could be put into an ES6 module and export the main function with only a few lines of code if you wanted.

Here's the origin of that code on stack overflow: pure JavaScript equivalent to jQuery's $.ready() how to call a function when the page/dom is ready for it

jfriend00
  • 580,699
  • 78
  • 809
  • 825