Movatterモバイル変換


[0]ホーム

URL:


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

A javascript trick to make modules embeddable in an HTML file.

License

NotificationsYou must be signed in to change notification settings

clickclickpwn/embeddable-modular-programming-example-for-Javascript

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

A trick I learned from working with CHATGPT, to solve an interesting problem I had.

How do we create modules of javascript, thats embeddable across the web, in one copy paste code, like you can do with google sites?

Many programmers useimport andexport, and multiple files, but I wanted to have it all one copy and paste, and have it leggible.

How this trick works is, you create your modules with the script tag, then you give them Id's to be called as objects.

Modules are just individualscripts in seperate files.

The difference between this and regualar module programming of javascript is:

It has to be layered in a specific order, like you do within an algorithm.

This is due to how the DOM loads things in HTML.

Its an HTML file, not a javascript one.

With this trick, you can create individual callable scripts as objects, that can be further troubleshot and debugged,

all embeddable.

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

4

Two scripts interacting and calling each other, from two seperate tags in the same html file.

This is Unlicensed, as a thank you toGod for giving me the privilege, Codecademy for the free knowledge, and chatGPT for the free helper to solve this complex problem that school couldn't.

I may provide more complex examples later.


[8]ページ先頭

©2009-2025 Movatter.jp