Changing jquery-min.js

For some reason, I want to add my jquery code to the end of jquery-min.js instead of using new separate file. My questions are:

  1. Can my code conflict with jquery library code?
  2. If somehow some browser does not execute my code (browser compatibility) will the code of jquery library work just ignoring my part of code?
  3. I have to put my code into the jquery-min.js, there are no other options, so how to prevent future possible conflict, any ideas?

Thanks in advance for your answers

Are you sure? For instance, have you considered concatenating the scripts in a build step or use an actual module bundler such as webpack?

Concatenating might be a simple cat command (probably defined in the scripts section of your package.json):

cat *.js >> my-jquery-build.js

Or with webpack you can define an array of scripts as entry point:

module.exports = {
  entry: ['jquery.min.js', 'my-script.js'],
  output: {
    filename: 'my-jquery-build.js'
  }
}

Other than that:

  1. No more than including it separately
  2. If you are using syntax older browsers don’t understand then yes, this will result in a parsing error and none of the code will be executed. Regular errors such as unsupported APIs shouldn’t be a problem though and can be caught
  3. Use a build step as described above so you can keep jQuery itself separate and up-to-date

thanks working on it

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.