javascript - Grunt task for combining multiple Jquery ready functions into single ready function -


i have ready functions spread across multiple files looking merge , minify. there grunt task merge ready 1 function ?

// file1.js $(document).ready(function(){     $(".class1").click(function () {         // action     }) })   // file2.js $(document).ready(function(){     $(".class3").on("blur", function () {         // action     }) })  // file3.js $(document).ready(function(){     $(".class2").on("change", function () {         // action     }) })  // file4.js $(document).ready(function(){     $(".class3").click(function () {         // action     }) }) 

i looking ...

// file.js $(document).ready(function(){     $(".class1").click(function () {         // action     })      $(".class3").on("blur", function () {         // action     })      $(".class2").on("change", function () {         // action     })      $(".class3").click(function () {         // action     }) }) 

will harm performance if run grunt task combine files , have multiple ready functions in file merged using grunt-contrib-uglify ?

// file.js $(document).ready(function(){     $(".class1").click(function () {         // action     }) })  $(document).ready(function(){     $(".class3").on("blur", function () {         // action     }) })  $(document).ready(function(){     $(".class2").on("change", function () {         // action     }) })  $(document).ready(function(){     $(".class3").click(function () {         // action     }) }) 

thank checking question out. have great day. sorry if repeat question. posting question because not find answer anywhere else.

you can use grunt-jquery-ready want.

you should concat first files , use grunt plugin in way. tested , works

grunt.initconfig({    'jquery-ready' : {        path: 'path_to_your_folder/your_script_file.js',        runsync: false    }       grunt.loadnpmtasks('grunt-jquery-ready');       grunt.registertask('default', "jquery-ready");  });
result after executing got file in format:

$(document).ready(function(){    content of script.js file placed here automatically.   });

please refer main website more information:

wrapping concatenated .js file ready function


Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -