1

In my project, one widget (embed to another site), there is a jQuery conflict issue with the parent website.

So now I need to create my own JS core file from jQuery core file. Is there any way to create custom JS from jQuery core file.

I have used the below script but still same problem.

  $.noConflict();
  jQuery(document).ready(function($) {
    // Code that uses jQuery's $ can follow here.
  });

i have used a few methods from the jQuery core. I want to create my own JS file from jQuery core file.

1 Answer 1

1

Use an anonymous function like so:

(function($) {
    //Insert your jQuery
}(jQuery))

What this does is allows you to use $ but passes jQuery to the anonymous function. Anonymous functions are also self-invoking, meaning it will automatically call itself when it is loaded.

If you wanted to include your own JavaScript file, you can utilize .getScript()

$.getScript(url, function() {
    //success stuff
})

I don't believe this will work if the script you want is on a different domain from where it is hosted though. XSS issues and what not.

Sign up to request clarification or add additional context in comments.

6 Comments

thanks for reply ....i know this but is there any way to create custom build for core jquery js ?
Are you talking about a separate file?
yes ..its include only methods and function that i have use. custom JS file so it will not conflict with any script.
@ManishLanga Check it out now
again thasnk to you..my requirement is we want to remove jquery from site and create my own jquery file with diff name.its not include jquery word or $ so i can avoid conflict issue with all other parent site.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.