Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new rule: Add JS/CSS file From URL #62

Open
Ronald-Diemicke opened this issue Jul 31, 2023 · 1 comment
Open

Add new rule: Add JS/CSS file From URL #62

Ronald-Diemicke opened this issue Jul 31, 2023 · 1 comment

Comments

@Ronald-Diemicke
Copy link

So - I recently realized I could use a feature where I could actually give RO a URL and have it add it to the page as a new script file or CSS file - so I could test a script I've got hosted elsewhere on a page BEFORE I commit to adding it...

@KevynTD
Copy link

KevynTD commented Feb 2, 2024

I was thinking the same thing. You can do it the following way, but it's not that practical, having an UI would make it a lot easier to edit.

// Bite code from https://stackoverflow.com/a/950146/6227108
function dynamicallyLoadScript(url) {
    var script = document.createElement("script");  // create a script DOM node
    script.src = url;  // set its src to the provided URL
   
    document.head.appendChild(script);  // add it to the end of the head section of the page (could change 'head' to 'body' to add it to the end of the body section instead)
}

// example
dynamicallyLoadScript('https://cdn.jsdelivr.net/momentjs/2.17.1/moment.min.js')

It would be nice to select if it is type="module" in the options too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants