-
Notifications
You must be signed in to change notification settings - Fork 100
id needed in script tag #78
Comments
it's needed to get the url for the sandbox to load[1]. The sandbox being the iframe on old browser, or the Web Worker in newer browsers. Which will contain the interpreter for security, isolation, and performance reasons. |
If you have better ideas, please would love to hear them |
I see now why it needs an id. One idea I had as a fallback at least: function endsWith(str, suffix) {
return str.indexOf(suffix, str.length - suffix.length) !== -1;
}
var script = document.getElementsByTagName('script');
for(var i = 0; i < script.length;i++){
if(endsWith(script[i].src, 'jsrepl.js')){
return script.src
}
} It's not ideal in the least, but it would remove (or negate the need of) the id system. It would simply need the name of the file to be jsrepl.js |
I feel that the name of the script is the most variable here. But that wouldn't hurt I guess. Maybe a regexp to look for jsrepl would be best. |
Sorry, I accidentally posted early. Why do you feel the name is the most variable? |
Another suggestion, what if when a user initializes jsrepl, they supply a src attribute if they need to deviate from the normal pattern? That should be unobtrusive, and flexible for any projects needs. |
Because people load the scripts from different folders and sometimes append version numbers to scripts. |
At least loading from folders is handled by my approach, but regex would be fine for testing src to see if it is jsrepl.js or some variant. I think a combination of manual override, searching script elements, and special id would provide coverage for almost all use cases and not be hard not implement. |
ah sorry, missed the |
Is there any way to move the loader script detection inside the loader class, or any easy way a user could manually initiate it? I will be glad to make a pull request implementing this, but it may have to wait for a bit because I have finals and don't know coffee-script at all. |
It seems possible but would take a little bit of refactoring. CoffeeScript is not that different from JS, try this book http://arcturo.github.io/library/coffeescript/ |
I realize that CoffeeScript is not very different, but it has different enough syntax that I can't whip up a pull request in a very short time. I will probably implement searching script tags by next week, but manual override will have to wait for a while. |
Why exactly does the script tag need to have an id?
This seems unnecessary and it would allow more diversity if jsrepl was not dependent on DOM . This is a particularly large problem when working with Chrome extensions, where you have no control over the background DOM.
The text was updated successfully, but these errors were encountered: