Categories
JavaScript Answers

How to import jQuery using ES6 syntax with JavaScript?

Spread the love

Sometimes, we want to import jQuery using ES6 syntax with JavaScript.

In this article, we’ll look at how to import jQuery using ES6 syntax with JavaScript.

How to import jQuery using ES6 syntax with JavaScript?

To import jQuery using ES6 syntax with JavaScript, we can use import.

For instance, we write

import { $, jQuery } from "jquery";

window.$ = $;
window.jQuery = jQuery;

to import $ and jQuery from the jquery module.

And then we assign $ and jQuery to properties of window with

window.$ = $;
window.jQuery = jQuery;

to make them global.

Conclusion

To import jQuery using ES6 syntax with JavaScript, we can use import.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *