H
H
hollolo2018-05-09 16:48:03
JavaScript
hollolo, 2018-05-09 16:48:03

How to import js library?

When I connect the js-library in head everything works.
If I import it as a module, then the function assignment to window (window.libraryName.foo ()) falls off
. What could be the matter?
What is the difference between including in head and importing?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Spirin, 2018-05-09
@hollolo

Why mankipatch window in modular code ?
Import the library into the file (module) in which you are using it.

import libraryName from 'libraryName';

libraryName.someMethod();

or:
import { someMethod } from 'libraryName';

someMethod();

Read the documentation for the library, everything is there.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question