I want to dynamically load JS file using AJAX and execute it. I am referring this page which says, "At this time,the preferred way of injecting JS code seems to be to use AJAX to load the JS source, then eval() the code."
But I am worried of using eval to execute the script. Just to see how jQuery implements this I checked its source and found this:
getScript: function( url, callback ) {
return jQuery.get( url, undefined, callback, "script" );
}
Then I searched for jQuery get method. But there are several get methods defined. I am new to OOP in JS and don't understand where to look for the correct get method.
I want to know how it executes the script - whether it uses eval or not and if yes, how is it secure.
Can someone guide me how I can look for the correct get method.