How to include Javascript from anonther ?

CK CK 3788 
Created at  
411 0 0

Actually there is such a function in PHP which function is "include".
It's very strong function.

But Javascript does not support such a function.

Here's the alternate method to do that.


To include javascript, following is using usually:

<script type="text/javascript" src="the_script.js"></script>


But above script is not available in Javascript so following is the alternate method to include another javascript.

the_another_javascript.js:

document.write( "<script type="text/javascript" src="the_script.js"></script>");

Isn't it simple ?

Actually the main logic above is writing script tag in the document.

Tags HTML ISO 8601 Format Javascript file_exists Facebook X
Comments 0
Similar posts
  1. Javascript based Browser Sniffing
    433
  2. Javascript based Regular Expression Tester
    374
  3. Two useful string functions - substr & substring
    407
  4. IFRAME Auto Resize in IE, FireFox by Javascript
    455
  5. How to check if a file exists ?
    789
  6. Is there URLEncode function in Javascript ?
    393
  7. Move window
    548
  8. How to calculate page loading time ?
    360
  9. Number Of Vists
    511
  10. Add Message On Mouse Traling
    2,557
  11. Tooltip
    408
  12. Document Fader
    346
  13. Book Mark This Site
    405
  14. Icon Coupled Url
    427
  15. Button That Will Close The Browser Window
    350
  16. Button That Will Show The Page's Source
    387
  17. Add A Scrolling Status Bar Text To Your Site
    408
  18. Add This Page To Favorites
    400
  19. Code To Clear Browser History
    375
  20. Remove the spaces before begin and after end of text
    336
  21. How To Close A Pop-up Window ?
    443
  22. Pop Up Window On Top
    516
  23. How to display message on browser status bar ?
    476
  24. New Window
    604
  25. Color Table
    365
  26. Cursor Changer
    383
  27. Dual Scroller
    332
  28. Enlarge Image
    514
  29. Confirm The Link Clicked
    631
  30. Select And Deselect All Checkboxes By Javascript
    632
  1. To hide/show area of web page without re-loading a page
    1,021
  2. Displays the html tags without rendering on a webpage
    352
  3. Javascript based query parser for AJAX application
    565
  4. To get web browser capability
    526
  5. Photo thumbnail viewer implemented in javascript
    487
  6. Javascript Confirmation
    593
  7. Javascript Prompts
    450
  8. How to know browser version in javascript ?
    444
  9. How to know the browser name in Javascript ?
    639
  10. Select All, None, Invert checkbox
    506
  11. Simple RSS Reader based on javascript
    502
  12. How to find the ip address of a client machine from a web application?
    518
  13. Put Date Time on HTML
    551
  14. IFRAME Auto Resize in IE, FireFox by Javascript
    455
  15. How to elimiate the "Restore Previous Session" dialog when FireFox 2.0 starts
    409
  16. Javascript based Browser Sniffing
    433
  17. Javascript based Regular Expression Tester
    374
  18. Two useful string functions - substr & substring
    407
  19. How to block a connection from the certain site ?
    352
  20. Is there URLEncode function in Javascript ?
    393
  21. Move window
    548
  22. How to calculate page loading time ?
    360
  23. Number Of Vists
    511
  24. Add Message On Mouse Traling
    2,557
  25. Tooltip
    408
  26. Document Fader
    346
  27. Book Mark This Site
    405
  28. Icon Coupled Url
    427
  29. Button That Will Close The Browser Window
    350
  30. Button That Will Show The Page's Source
    387
Recently updated
  1. Why 100% SEO Guarantees Better User Engagement and How to Achieve It in Your Service
    40
  2. Why SPF and DKIM Are Essential for Linux Email Servers?
    34
  3. How do I create animated background for Google Meet?
    20,611
  4. MaxMind GeoLite2 vs. DB-IP Lite vs. ip-api.com: Choosing the Right Free IP Geolocation Solution
    244
  5. Meet Valkey: Why Redis Changed Its License, Why Valkey is Better, and How to Use It as a Drop-in Replacement
    94
  6. How Rogue Web Scrapers Are Stealing My Content and Destroying My Server
    157
  7. Array of arguments passed to script in PHP
    90
  8. Invalid Auction Storms in Ad Tech
    98
  9. Building MRC-Compliant Instrumentation in Ad Tech: Implementation Steps and Key Challenges
    202
  10. The Two Clocks of Ad Server Architecture
    70
  11. Frequency Cap Architecture Overview
    514
  12. Collecting Proof-of-Play from 100,000 Screens
    146
  13. Vector Search in Relational Databases (RDBs): Trends & Usage Environments
    287
  14. What is RedisVL?
    109
  15. Designing a Skill Registry Architecture: Minimize Token Usage and Maximize AI Performance
    230
  16. TPU & GPU Cluster Management Tools
    244
  17. The Concept of Scaffolding in AI Agents
    233
  18. Beyond Static Pipelines: Architecting LLM Multi-Agent Systems for Autonomous Workflow Orchestration
    583
  19. AI-DLC vs. AI-SDLC: Model-Centric vs. System-Centric AI Development
    258
  20. Fine-Tuning Open-Weight LLMs: Training, Licensing, and Deploying Custom Models with Ollama
    339
  21. Inside the Next-Generation Streaming Architecture: Ultra-Low Latency, SGAI, and AI Codecs
    202
  22. Machine Learning: Training vs. Ranking
    221
  23. The Continuous Learning Machine: Designing a Loop That Actually Turns
    222
  24. The Next-Gen Low-Latency Standards: LL-HLS & MoQ
    195
  25. Designing a Data Curation System Around a Vector Database
    220
  26. Extracting Context from Live Video: The Architecture Got Simpler When We Stopped Building Features
    256
  27. The New Ad Stack Behind Live Sports Streaming: Inside SGAI, EABN, and the Standards Race to Fix Live Monetization
    656
  28. Designing MLOps Architectures to Handle Seasonal Data Drift in EV Fleet Models
    195
  29. From 15 to 40+ FPS: Accelerating PyTorch Object Detection on Automotive ECUs
    217
  30. Understanding Data Lineage
    260