Reputation: 11609
I am experiencing some issue when loading some javascript file. I am using some jquery plugin and to make it work, I had to add the several required javascript files just before the closing body tag. Now I want these files to be loaded for some specific url
, so I tried this
$(document).ready(function(){
if(window.location.href.indexOf("some url") > -1) {
$.getScript("my_different_files.js");}
});
but now the plugin doesn't work (I won't detail the error because I only changed the javascript
files loading process). What is the best way to mimic the javascript source loading using some url
conditioned load ?
Upvotes: 0
Views: 161
Reputation: 2090
A better approach for such a task would be to use some module loading/management library like RequireJS. This is some example code on how you can do that with RequireJS
Upvotes: 1