Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c387ed4

Browse files
Create README.md
to help the future understand
1 parent 9d3cd49 commit c387ed4

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

‎README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# embeddable-modular-programming-example-for-Javascript
2+
3+
4+
A trick I learned from working with CHATGPT, to solve an interesting problem I had.
5+
6+
How do we create modules of javascript, thats embeddable across the web, in one copy paste code, like you can do with google sites?
7+
8+
9+
Many programmers use import and export, and multiple files, but I wanted to have it all one copy and paste, and have it leggible.
10+
11+
12+
How this trick works is, you create your modules with the script tag, then you give them Id's to be called as objects.
13+
14+
15+
Modules are just individual <scripts> in seperate files. The difference between this and regualar module programming of javascript is:
16+
17+
18+
19+
It has to be layered in a specific order, like you do within an algorithm.
20+
21+
This is due to how the DOM loads things in HTML.
22+
23+
Its an HTML file, not a javascript one.
24+
25+
26+
27+
With this trick, you can create individual callable scripts as objects, that can be further troubleshot and debugged,
28+
29+
all embeddable.
30+
31+
32+
33+
34+
To check if it works, run the file, which is a blank white screen, and hit inspect to read the console.log to see the sum equal
35+
36+
4
37+
38+
39+
40+
Two scripts interacting and calling each other, from two seperate tags in the same html file.
41+
42+
43+
44+
45+
I may provide more complex examples later.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /