Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/grvpanchal/loading-scripts
The repo explain the different way to load script tag containing JavaScript onto you website.
https://github.com/grvpanchal/loading-scripts
Last synced: 10 days ago
JSON representation
The repo explain the different way to load script tag containing JavaScript onto you website.
- Host: GitHub
- URL: https://github.com/grvpanchal/loading-scripts
- Owner: grvpanchal
- Created: 2020-05-01T21:53:43.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-05-01T21:54:57.000Z (over 4 years ago)
- Last Synced: 2024-11-12T04:35:10.940Z (2 months ago)
- Language: HTML
- Size: 23.4 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Ways of loading JavaScript via loading scripts tags
## Description
The repo explain the different way to load script tag containing JavaScript onto you website.## Setup
Install Packages
```sh
npm install
```
Start the server
```sh
npm start
```Access you server via http://localhost:5000
# Information
This repo demonstrates the 5 ways import JavaScript via `` tag
1. Normal Script Tag
```html
<script>
function createWorld() {
const h2Element = document.createElement('h2');
h2Element.innerHTML = 'Content loaded via script tag';
document.body.appendChild(h2Element);
}createWorld();
```
2. Script Tag with local Resource file
```html```
3. Script Tag with External Resource file
```html```
4. Script Tag that dynamically loads a script file
```htmlfunction loadScriptDynamically(src) {
const scriptElement = document.createElement('script');
scriptElement.src = src;
document.head.appendChild(scriptElement);
}setTimeout(() => loadScriptDynamically('./assets/js/createDynamicInsertWorld.js'), 3000);
```
5. Script Tag that supports ES6 Module Import
```html```
I hope I have covered all ways. Address bar way not considered. Please let me know if you guys know additional