Nick Maddren
Nick Maddren

Reputation: 661

Use two variables for require package in JavaScript

What is the best way to include two variables for a single package that is required in JavaScript?

I have an example here:

$ = require('jquery');

At the moment I simply use $ however some of my project uses jQuery which I cannot change.

$, jQuery = require('jquery');

However this did not work which was expected to be honest.

This works however it isn't ideal as it will be requiring the package twice wont it?

$ = require('jquery');
jQuery = require('jquery');

Thanks

Upvotes: 1

Views: 95

Answers (1)

Selvakumar
Selvakumar

Reputation: 537

var $ = jQuery = require('jquery');

Upvotes: 3

Related Questions