Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Welcome to Software Development on Codidact!

Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.

Comments on How to run a remote JavaScript file from GitHub?

Parent

How to run a remote JavaScript file from GitHub?

+3
−3

I have a JavaScript file in GitHub which I typically run by copy-pasting all its data into different user script managers (USMs) on different web browsers.

I need to start executing that remote file directly from GitHub instead, because for me it's a problem to maintain two or more versions, each one for each browser (Chrome, FireFox, Edge, etc.), rather, I want to maintain just one version in GitHub and to call it from each browser's USM (each browser might have a different USM with different internal commands, compatibility and caching).

To clarify, I don't mean to sync a script from one USM account to another (as with Greasemonkey synching); I just want to call a script that is being stored on GitHub, instead storing it locally, but only with JavaScript in way totally unified for all USMs.

Update

As Alexei noted in the comment section I can use // @require command but I still seek a JavaScript approach because it will save me a deal with USM caching, syntax compatibility and possible bugs.

History
Why does this post require moderator attention?
You might want to add some details to your flag.
Why should this post be closed?

1 comment thread

Clarify the actual need (8 comments)
Post
+0
−1
        const script = document.createElement('script');
        
        script.src = `your.script.url/?_bustcache=${Date.now()}`;
        script.async = true;
        script.onload = doSomething;

        document.head.appendChild(script);

        async function doSomething() {
              // do stuff once its loaded
        }

History
Why does this post require moderator attention?
You might want to add some details to your flag.

1 comment thread

Please avoid providing code only answers (1 comment)
Please avoid providing code only answers
Alexei‭ wrote over 2 years ago

Can you please also provide some explanation besides the code? This helps future readers understand the proposed solution.