Loading jQuery inside ES5 strict mode function

I would like to import jQuery inside an IIFE scope as follows:

(function (window, document) {
    "use strict";
    /* Content of jquery.min.js goes here */
    /* Code that uses $ goes here */
}(window, document));

Now I run a severe mode violation as soon as this code runs, possibly because jQuery itself does not match:

In strict mode code, functions can only be declared at the top level or immediately within another function.

Is there a way to load jQuery only within the same scope, while maintaining strict mode for the rest of the code that relies on it?

+4
source share
1 answer
+2

Source: https://habr.com/ru/post/1545542/


All Articles