Answer the question
In order to leave comments, you need to log in
Does webpack make it possible to include the desired module in inline js, like requirejs does?
I am trying to start using webpack. I wrapped everything in modules, formed a bundle. But I have a piece of inline code on the page that depends on jquery. But webpack pulls jquery asynchronously and at the moment when the page execution reaches the inline script, jquery is not available. With requirejs it would look like this:
require([ 'jquery' ], function ($) {
// делаю что-то, используя jquery
console.log($);
});
Answer the question
In order to leave comments, you need to log in
One of the webpack developers recommends using ded/script.js :
var $script = require("scriptjs");
$script("//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js", function() {
$('body').html('It works!')
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question